parser: fix infnite loop with `fn foo(&) {}`

pull/2940/head
Alexander Medvednikov 2019-11-30 10:21:58 +03:00
parent d71532b64e
commit c00a7f3a5e
1 changed files with 11 additions and 7 deletions

View File

@ -331,7 +331,8 @@ fn (p mut Parser) fn_decl() {
// `os.exit()` ==> `os__exit()`
// if !is_c && !p.builtin_mod && receiver_typ.len == 0 {
if !is_c && !has_receiver &&
(!p.builtin_mod || (p.builtin_mod && f.name == 'init')) {
(!p.builtin_mod || (p.builtin_mod && f.name == 'init'))
{
f.name = p.prepend_mod(f.name)
}
if p.first_pass() && receiver_typ.len == 0 {
@ -848,6 +849,9 @@ fn (p mut Parser) fn_args(f mut Fn) {
if types_only {
for p.tok != .rpar {
typ := p.get_type()
if typ == '' && !f.is_c {
p.error('bad fn arg type')
}
p.check_and_register_used_imported_type(typ)
v := Var {
typ: typ