parser: do not allow string{} outside of builtin

pull/4170/head
Alexander Medvednikov 2020-03-31 21:03:21 +02:00
parent a3bd19ce73
commit 050ec5d9e3
3 changed files with 15 additions and 18 deletions

View File

@ -120,7 +120,7 @@ fn filter_num_sep(txt byteptr, start int, end int) string {
i++
}
b[i1]=0 // C string compatibility
return string{str:b len:i1}
return string(b, i1)
}
}

View File

@ -667,7 +667,7 @@ pub fn (p mut Parser) name_expr() ast.Expr {
}
else if p.peek_tok.kind == .lcbr && (p.tok.lit[0].is_capital() || is_c ||
//
p.tok.lit in table.builtin_type_names) &&
(p.builtin_mod && p.tok.lit in table.builtin_type_names)) &&
//
(p.tok.lit.len == 1 || !p.tok.lit[p.tok.lit.len - 1].is_capital())
//
@ -822,7 +822,7 @@ pub fn (p mut Parser) expr(precedence int) ast.Expr {
p.error('unknown variable `$name`')
return node
}
println('assoc var $name typ=$var.typ')
// println('assoc var $name typ=$var.typ')
mut fields := []string
mut vals := []ast.Expr
p.check(.pipe)

View File

@ -124,10 +124,7 @@ fn filter_num_sep(txt byteptr, start int, end int) string {
i++
}
b[i1] = 0 // C string compatibility
return string{
str: b
len: i1
}
return string(b,i1)
}
}