compiler: fix issue #1612 .

pull/1625/head
Delyan Angelov 2019-08-16 13:40:08 +03:00 committed by Alexander Medvednikov
parent c156cef972
commit 5ea4b463bb
1 changed files with 4 additions and 1 deletions

View File

@ -348,6 +348,7 @@ fn (p mut Parser) fn_decl() {
if !is_sig && !is_fn_header {
mut opened_scopes := 0
mut closed_scopes := 0
mut temp_scanner_pos := 0
for {
if p.tok == .lcbr {
opened_scopes++
@ -360,6 +361,7 @@ fn (p mut Parser) fn_decl() {
// TODO remove this once tokens are cached
if p.tok == .gt && p.prev_tok == .name && p.prev_tok2 == .lt &&
p.scanner.text[p.scanner.pos-1] != `T` {
temp_scanner_pos = p.scanner.pos
p.scanner.pos -= 3
for p.scanner.pos > 0 && (is_name_char(p.scanner.text[p.scanner.pos]) ||
p.scanner.text[p.scanner.pos] == `.` ||
@ -370,6 +372,7 @@ fn (p mut Parser) fn_decl() {
p.next()
// Run the function in the firt pass to register the generic type
p.name_expr()
p.scanner.pos = temp_scanner_pos
}
if p.tok.is_decl() && !(p.prev_tok == .dot && p.tok == .key_type) {
break