Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 26, 2023
1 parent e1a474e commit 7492d0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -3176,7 +3176,8 @@ fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
c.error('cannot cast string to `${tt}` outside `unsafe`, use ${tt}(s.str) instead',
node.pos)
} else if final_from_sym.kind == .array && !from_type.is_ptr() && to_type != ast.string_type
&& !(to_type.has_flag(.option) && from_type.idx() == to_type.idx()) {
&& !(to_type.has_flag(.option) && from_type.idx() == to_type.idx())
&& to_sym.kind != final_from_sym.kind {
ft := c.table.type_to_str(from_type)
tt := c.table.type_to_str(to_type)
c.error('cannot cast array `${ft}` to `${tt}`', node.pos)
Expand Down
3 changes: 2 additions & 1 deletion vlib/v/parser/expr.v
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
if p.expecting_type {
// parse json.decode type (`json.decode([]User, s)`)
node = p.name_expr()
} else if p.is_amp && p.peek_tok.kind == .rsbr {
} else if (p.is_amp && p.peek_tok.kind == .rsbr)
|| (p.peek_tok.kind == .rsbr && p.peek_token(3).kind == .lpar) {
mut n := 2
mut peek_n_tok := p.peek_token(n)
for peek_n_tok.kind in [.name, .dot] {
Expand Down

0 comments on commit 7492d0f

Please sign in to comment.