mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: fix issue #1612 .
This commit is contained in:
parent
c156cef972
commit
5ea4b463bb
|
@ -348,6 +348,7 @@ fn (p mut Parser) fn_decl() {
|
||||||
if !is_sig && !is_fn_header {
|
if !is_sig && !is_fn_header {
|
||||||
mut opened_scopes := 0
|
mut opened_scopes := 0
|
||||||
mut closed_scopes := 0
|
mut closed_scopes := 0
|
||||||
|
mut temp_scanner_pos := 0
|
||||||
for {
|
for {
|
||||||
if p.tok == .lcbr {
|
if p.tok == .lcbr {
|
||||||
opened_scopes++
|
opened_scopes++
|
||||||
|
@ -359,7 +360,8 @@ fn (p mut Parser) fn_decl() {
|
||||||
// find `foo<Bar>()` in function bodies and register generic types
|
// find `foo<Bar>()` in function bodies and register generic types
|
||||||
// TODO remove this once tokens are cached
|
// TODO remove this once tokens are cached
|
||||||
if p.tok == .gt && p.prev_tok == .name && p.prev_tok2 == .lt &&
|
if p.tok == .gt && p.prev_tok == .name && p.prev_tok2 == .lt &&
|
||||||
p.scanner.text[p.scanner.pos-1] != `T` {
|
p.scanner.text[p.scanner.pos-1] != `T` {
|
||||||
|
temp_scanner_pos = p.scanner.pos
|
||||||
p.scanner.pos -= 3
|
p.scanner.pos -= 3
|
||||||
for p.scanner.pos > 0 && (is_name_char(p.scanner.text[p.scanner.pos]) ||
|
for p.scanner.pos > 0 && (is_name_char(p.scanner.text[p.scanner.pos]) ||
|
||||||
p.scanner.text[p.scanner.pos] == `.` ||
|
p.scanner.text[p.scanner.pos] == `.` ||
|
||||||
|
@ -370,6 +372,7 @@ fn (p mut Parser) fn_decl() {
|
||||||
p.next()
|
p.next()
|
||||||
// Run the function in the firt pass to register the generic type
|
// Run the function in the firt pass to register the generic type
|
||||||
p.name_expr()
|
p.name_expr()
|
||||||
|
p.scanner.pos = temp_scanner_pos
|
||||||
}
|
}
|
||||||
if p.tok.is_decl() && !(p.prev_tok == .dot && p.tok == .key_type) {
|
if p.tok.is_decl() && !(p.prev_tok == .dot && p.tok == .key_type) {
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user