mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: turn the pointer map notice into a warning and fix all code using it
This commit is contained in:
parent
e8108f21e0
commit
aba7bcde85
@ -1,10 +1,11 @@
|
|||||||
## V 0.3.3
|
## V 0.3.3
|
||||||
*Not yet released*
|
*Not yet released*
|
||||||
- add `math.vec` module for generic vector math.
|
- Accessing a pointer map value requires an `or{}` block outside `unsafe`.
|
||||||
|
- `math.vec` module for generic vector math.
|
||||||
- `go foo()` has been replaced with `spawn foo()` (launches an OS thread, `go` will be used for
|
- `go foo()` has been replaced with `spawn foo()` (launches an OS thread, `go` will be used for
|
||||||
upcoming coroutines instead).
|
upcoming coroutines instead).
|
||||||
- vfmt now supports `// vfmt off` and `// vfmt on` for turning off the formatting locally for *short* snippets of code. Useful for keeping your carefully arranged matrices intact.
|
- vfmt now supports `// vfmt off` and `// vfmt on` for turning off the formatting locally for *short* snippets of code. Useful for keeping your carefully arranged matrices intact.
|
||||||
- support match branch range expressions with consts: `match x { const1...const2 {} }`
|
- Match branch range expressions with consts: `match x { const1...const2 {} }`
|
||||||
|
|
||||||
## V 0.3.2
|
## V 0.3.2
|
||||||
*31 Oct 2022*
|
*31 Oct 2022*
|
||||||
|
@ -38,7 +38,7 @@ fn start_server() ! {
|
|||||||
slog('s.on_message_ref')
|
slog('s.on_message_ref')
|
||||||
// for _, cli in m.clients {
|
// for _, cli in m.clients {
|
||||||
for i, _ in m.clients {
|
for i, _ in m.clients {
|
||||||
mut c := m.clients[i]
|
mut c := m.clients[i] or { continue }
|
||||||
if c.client.state == .open && c.client.id != ws.id {
|
if c.client.state == .open && c.client.id != ws.id {
|
||||||
c.client.write(msg.payload, websocket.OPCode.text_frame) or { panic(err) }
|
c.client.write(msg.payload, websocket.OPCode.text_frame) or { panic(err) }
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ fn (mut s Server) handle_ping() {
|
|||||||
for s.state == .open {
|
for s.state == .open {
|
||||||
time.sleep(s.ping_interval * time.second)
|
time.sleep(s.ping_interval * time.second)
|
||||||
for i, _ in s.clients {
|
for i, _ in s.clients {
|
||||||
mut c := s.clients[i]
|
mut c := s.clients[i] or { continue }
|
||||||
if c.client.state == .open {
|
if c.client.state == .open {
|
||||||
c.client.ping() or {
|
c.client.ping() or {
|
||||||
s.logger.debug('server-> error sending ping to client')
|
s.logger.debug('server-> error sending ping to client')
|
||||||
@ -125,8 +125,10 @@ fn (mut s Server) serve_client(mut c Client) ! {
|
|||||||
// the client is accepted
|
// the client is accepted
|
||||||
c.socket_write(handshake_response.bytes())!
|
c.socket_write(handshake_response.bytes())!
|
||||||
lock {
|
lock {
|
||||||
|
unsafe {
|
||||||
s.clients[server_client.client.id] = server_client
|
s.clients[server_client.client.id] = server_client
|
||||||
}
|
}
|
||||||
|
}
|
||||||
s.setup_callbacks(mut server_client)
|
s.setup_callbacks(mut server_client)
|
||||||
c.listen() or {
|
c.listen() or {
|
||||||
s.logger.error(err.msg())
|
s.logger.error(err.msg())
|
||||||
|
@ -3818,7 +3818,7 @@ fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type {
|
|||||||
if !c.inside_unsafe && !c.is_builtin_mod && typ_sym.kind == .map && node.or_expr.stmts.len == 0 {
|
if !c.inside_unsafe && !c.is_builtin_mod && typ_sym.kind == .map && node.or_expr.stmts.len == 0 {
|
||||||
elem_type := c.table.value_type(typ)
|
elem_type := c.table.value_type(typ)
|
||||||
if elem_type.is_real_pointer() {
|
if elem_type.is_real_pointer() {
|
||||||
c.note('accessing a pointer map value requires an `or{}` block outside `unsafe`',
|
c.warn('accessing a pointer map value requires an `or{}` block outside `unsafe`',
|
||||||
node.pos)
|
node.pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,8 @@ fn (g &JsGen) get_all_test_function_names() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut g JsGen) enter_namespace(name string) {
|
pub fn (mut g JsGen) enter_namespace(name string) {
|
||||||
if unsafe { g.namespaces[name] == 0 } {
|
unsafe {
|
||||||
|
if g.namespaces[name] == 0 {
|
||||||
// create a new namespace
|
// create a new namespace
|
||||||
ns := &Namespace{
|
ns := &Namespace{
|
||||||
name: name
|
name: name
|
||||||
@ -422,6 +423,7 @@ pub fn (mut g JsGen) enter_namespace(name string) {
|
|||||||
} else {
|
} else {
|
||||||
g.ns = g.namespaces[name]
|
g.ns = g.namespaces[name]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
g.inside_builtin = name == 'builtin'
|
g.inside_builtin = name == 'builtin'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user