parser: fix treating JS fn calls as type casts (#6779)

pull/6785/head
spaceface777 2020-11-08 19:33:55 +01:00 committed by GitHub
parent 68cfbd6d66
commit 3c83551dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -30,6 +30,7 @@ fn class(extends string, instanceof int) {
fn main() {
println('Hello from V.js!')
println(JS.Math.atan2(1, 0))
println(JS.eval("console.log('Hello!')"))
mut a := 1
a *= 2
a += 3

View File

@ -1062,7 +1062,7 @@ pub fn (mut p Parser) name_expr() ast.Expr {
// if name in table.builtin_type_names {
if (!known_var && (name in p.table.type_idxs ||
name_w_mod in p.table.type_idxs) && name !in ['C.stat', 'C.sigaction']) ||
is_mod_cast || (!(name.len > 1 && name[0] == `C` && name[1] == `.`) && name[0].is_capital()) {
is_mod_cast || (language == .v && name[0].is_capital()) {
// MainLetter(x) is *always* a cast, as long as it is not `C.`
// TODO handle C.stat()
start_pos := p.tok.position()