From 5ea4b463bb52e33e40b31df1e53f586c6a512832 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 16 Aug 2019 13:40:08 +0300 Subject: [PATCH] compiler: fix issue #1612 . --- compiler/fn.v | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/fn.v b/compiler/fn.v index 64d1d73cf5..b3537b3f9b 100644 --- a/compiler/fn.v +++ b/compiler/fn.v @@ -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++ @@ -359,7 +360,8 @@ fn (p mut Parser) fn_decl() { // find `foo()` in function bodies and register generic types // 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` { + 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