do not allow `go print()`
parent
c8a781bf77
commit
b6bb6a5a60
|
@ -188,11 +188,16 @@ fn main() {
|
||||||
// TODO remove
|
// TODO remove
|
||||||
if v.pref.autofree {
|
if v.pref.autofree {
|
||||||
println('started freeing v struct')
|
println('started freeing v struct')
|
||||||
v.table.fns.free()
|
|
||||||
v.table.typesmap.free()
|
v.table.typesmap.free()
|
||||||
v.table.obf_ids.free()
|
v.table.obf_ids.free()
|
||||||
v.cgen.lines.free()
|
v.cgen.lines.free()
|
||||||
free(v.cgen)
|
free(v.cgen)
|
||||||
|
for _, f in v.table.fns {
|
||||||
|
f.local_vars.free()
|
||||||
|
f.args.free()
|
||||||
|
//f.defer_text.free()
|
||||||
|
}
|
||||||
|
v.table.fns.free()
|
||||||
free(v.table)
|
free(v.table)
|
||||||
//for p in parsers {
|
//for p in parsers {
|
||||||
|
|
||||||
|
@ -226,6 +231,8 @@ fn (v mut V) compile() {
|
||||||
for file in v.files {
|
for file in v.files {
|
||||||
mut p := v.new_parser(file)
|
mut p := v.new_parser(file)
|
||||||
p.parse(.decl)
|
p.parse(.decl)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Main pass
|
// Main pass
|
||||||
cgen.pass = Pass.main
|
cgen.pass = Pass.main
|
||||||
|
|
|
@ -17,8 +17,9 @@ struct Parser {
|
||||||
file_pcguard string // When p.file_pcguard != '', it contains a
|
file_pcguard string // When p.file_pcguard != '', it contains a
|
||||||
// C ifdef guard clause that must be put before
|
// C ifdef guard clause that must be put before
|
||||||
// the #include directives in the parsed .v file
|
// the #include directives in the parsed .v file
|
||||||
mut:
|
|
||||||
v &V
|
v &V
|
||||||
|
pref &Preferences // Preferences shared from V struct
|
||||||
|
mut:
|
||||||
scanner &Scanner
|
scanner &Scanner
|
||||||
// tokens []Token // TODO cache all tokens, right now they have to be scanned twice
|
// tokens []Token // TODO cache all tokens, right now they have to be scanned twice
|
||||||
token_idx int
|
token_idx int
|
||||||
|
@ -40,7 +41,6 @@ mut:
|
||||||
expected_type string
|
expected_type string
|
||||||
tmp_cnt int
|
tmp_cnt int
|
||||||
is_script bool
|
is_script bool
|
||||||
pref &Preferences // Preferences shared from V struct
|
|
||||||
builtin_mod bool
|
builtin_mod bool
|
||||||
vh_lines []string
|
vh_lines []string
|
||||||
inside_if_expr bool
|
inside_if_expr bool
|
||||||
|
@ -1078,7 +1078,7 @@ fn (p mut Parser) close_scope() {
|
||||||
free_fn = 'v_array_free'
|
free_fn = 'v_array_free'
|
||||||
} else if v.typ == 'string' {
|
} else if v.typ == 'string' {
|
||||||
free_fn = 'v_string_free'
|
free_fn = 'v_string_free'
|
||||||
//continue
|
continue
|
||||||
} else if v.ptr || v.typ.ends_with('*') {
|
} else if v.ptr || v.typ.ends_with('*') {
|
||||||
free_fn = 'v_ptr_free'
|
free_fn = 'v_ptr_free'
|
||||||
//continue
|
//continue
|
||||||
|
@ -3562,7 +3562,7 @@ fn (p mut Parser) go_statement() {
|
||||||
// Normal function
|
// Normal function
|
||||||
else {
|
else {
|
||||||
f := p.table.find_fn(p.lit) or { panic('fn') }
|
f := p.table.find_fn(p.lit) or { panic('fn') }
|
||||||
if f.name == 'println' {
|
if f.name == 'println' || f.name == 'print' {
|
||||||
p.error('`go` cannot be used with `println`')
|
p.error('`go` cannot be used with `println`')
|
||||||
}
|
}
|
||||||
p.async_fn_call(f, 0, '', '')
|
p.async_fn_call(f, 0, '', '')
|
||||||
|
|
Loading…
Reference in New Issue