Revert "parser: fix panic when single letter receiver parsed (#8381)"
This reverts commit 93b0d8ca64
.
pull/8391/head
parent
93b0d8ca64
commit
36e75e5208
|
@ -5296,7 +5296,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
||||||
sym := c.table.get_type_symbol(arg.typ)
|
sym := c.table.get_type_symbol(arg.typ)
|
||||||
if sym.kind == .placeholder
|
if sym.kind == .placeholder
|
||||||
|| (sym.kind in [table.Kind.int_literal, .float_literal] && !c.is_builtin_mod) {
|
|| (sym.kind in [table.Kind.int_literal, .float_literal] && !c.is_builtin_mod) {
|
||||||
c.error('unknown type `$sym.name`', node.receiver_pos)
|
c.error('unknown type `$sym.name`', node.pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
vlib/v/checker/tests/receiver_unknown_type_single_letter.vv:1:5: error: unknown type `A`
|
|
||||||
1 | fn (p A) foo() {}
|
|
||||||
| ~~~
|
|
|
@ -1 +0,0 @@
|
||||||
fn (p A) foo() {}
|
|
|
@ -190,7 +190,6 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||||
mut rec_mut := false
|
mut rec_mut := false
|
||||||
mut params := []table.Param{}
|
mut params := []table.Param{}
|
||||||
if p.tok.kind == .lpar {
|
if p.tok.kind == .lpar {
|
||||||
p.is_parsing_receiver = true
|
|
||||||
lpar_pos := p.tok.position()
|
lpar_pos := p.tok.position()
|
||||||
p.next() // (
|
p.next() // (
|
||||||
is_method = true
|
is_method = true
|
||||||
|
@ -247,7 +246,6 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||||
typ: rec_type
|
typ: rec_type
|
||||||
}
|
}
|
||||||
p.check(.rpar)
|
p.check(.rpar)
|
||||||
p.is_parsing_receiver = false
|
|
||||||
}
|
}
|
||||||
mut name := ''
|
mut name := ''
|
||||||
if p.tok.kind == .name {
|
if p.tok.kind == .name {
|
||||||
|
|
|
@ -373,7 +373,7 @@ pub fn (mut p Parser) parse_any_type(language table.Language, is_ptr bool, check
|
||||||
return table.int_literal_type
|
return table.int_literal_type
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if name.len == 1 && name[0].is_capital() && !p.is_parsing_receiver {
|
if name.len == 1 && name[0].is_capital() {
|
||||||
return p.parse_generic_template_type(name)
|
return p.parse_generic_template_type(name)
|
||||||
}
|
}
|
||||||
if p.peek_tok.kind == .lt {
|
if p.peek_tok.kind == .lt {
|
||||||
|
|
|
@ -71,7 +71,6 @@ mut:
|
||||||
cur_fn_name string
|
cur_fn_name string
|
||||||
in_generic_params bool // indicates if parsing between `<` and `>` of a method/function
|
in_generic_params bool // indicates if parsing between `<` and `>` of a method/function
|
||||||
name_error bool // indicates if the token is not a name or the name is on another line
|
name_error bool // indicates if the token is not a name or the name is on another line
|
||||||
is_parsing_receiver bool // indicates if parser is parsing receiver fn (x Xxx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for tests
|
// for tests
|
||||||
|
|
Loading…
Reference in New Issue