mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
add support for errcode in or{} optional blocks.
This commit is contained in:
parent
abd0686043
commit
b0567543c9
@ -834,10 +834,12 @@ pub fn (c mut Checker) expr(node ast.Expr) table.Type {
|
||||
it.expr_type = c.expr(it.expr)
|
||||
return table.string_type
|
||||
}
|
||||
else {}
|
||||
// println('checker.expr(): unhandled node')
|
||||
// TODO: find nil string bug triggered with typeof
|
||||
// println('checker.expr(): unhandled node (${typeof(node)})')
|
||||
else {
|
||||
tnode := typeof(node)
|
||||
if tnode != 'unknown v.ast.Expr' {
|
||||
println('checker.expr(): unhandled node with typeof(`${tnode}`)')
|
||||
}
|
||||
}
|
||||
}
|
||||
return table.void_type
|
||||
}
|
||||
|
@ -23,6 +23,10 @@ pub fn (p mut Parser) call_expr(is_c bool, mod string) ast.CallExpr {
|
||||
name: 'err'
|
||||
typ: table.string_type
|
||||
})
|
||||
p.scope.register('errcode', ast.Var{
|
||||
name: 'errcode'
|
||||
typ: table.int_type
|
||||
})
|
||||
or_stmts = p.parse_block_no_scope()
|
||||
p.close_scope()
|
||||
}
|
||||
|
@ -965,6 +965,10 @@ fn (p mut Parser) dot_expr(left ast.Expr) ast.Expr {
|
||||
if p.tok.kind == .key_orelse {
|
||||
p.next()
|
||||
p.open_scope()
|
||||
p.scope.register('errcode', ast.Var{
|
||||
name: 'errcode'
|
||||
typ: table.int_type
|
||||
})
|
||||
p.scope.register('err', ast.Var{
|
||||
name: 'err'
|
||||
typ: table.string_type
|
||||
|
Loading…
Reference in New Issue
Block a user