parser: fix JS functions starting with caps

pull/5190/head
spaceface777 2020-06-03 10:57:32 +02:00 committed by GitHub
parent d182059ba6
commit 4b7c70caca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,5 @@
// V_COMMIT_HASH 2943bdc
// V_CURRENT_COMMIT_HASH ad5deef
// V_COMMIT_HASH 11e6734
// V_CURRENT_COMMIT_HASH 99c70cf
// Generated by the V compiler
"use strict";
@ -187,17 +187,18 @@ const main = (function (hl) {
/* program entry point */
(async function() {
builtin.println("Hello from V.js!");
builtin.println(Math.atan2(1, 0));
/** @type {number} */
let a = 1;
a *= 2;
a += 3;
builtin.println(a);
/** @type {hl["Aaa"]["prototype"]} */
const b = new hl.Aaa({});
let b = new hl.Aaa({});
b.update("an update");
builtin.println(b);
/** @type {Foo} */
const c = new Foo({
let c = new Foo({
a: new hl.Aaa({})
});
c.a.update("another update");

View File

@ -1,6 +1,7 @@
import hello as hl
fn JS.alert(arg string)
fn JS.Math.atan2(f64, f64) f64
const (
i_am_a_const = 21214
@ -8,6 +9,7 @@ const (
)
struct Foo {
mut:
a hl.Aaa
}
@ -29,17 +31,18 @@ fn class(extends string, instanceof int) {
fn main() {
println('Hello from V.js!')
println(JS.Math.atan2(1, 0))
mut a := 1
a *= 2
a += 3
println(a) // TODO: Handle string interpolation
b := hl.Aaa{}
mut b := hl.Aaa{}
b.update('an update')
println(b)
c := Foo{ hl.Aaa{} }
mut c := Foo{ hl.Aaa{} }
c.a.update('another update')
println(c)

View File

@ -890,7 +890,7 @@ pub fn (mut p Parser) name_expr() ast.Expr {
} else if p.peek_tok.kind == .lcbr && !p.inside_match && !p.inside_match_case && !p.inside_if &&
!p.inside_for {
return p.struct_init(false) // short_syntax: false
} else if p.peek_tok.kind == .dot && (p.tok.lit[0].is_capital() && !known_var) {
} else if p.peek_tok.kind == .dot && (p.tok.lit[0].is_capital() && !known_var && language == .v) {
// `Color.green`
mut enum_name := p.check_name()
if mod != '' {