V: parser: looping error when parsing `type callback fn (int,const char*[])`

Created on 27 May 2020  路  4Comments  路  Source: vlang/v

V version:
0.1.27

Running 'v fmt' on following code will keep allocating memory until the OS runs out.
I realize this is not V code, nevertheless an error should be returned as soon as the formatting fails

module main

type callback fn (int,const char*[])
Bug vfmt

Most helpful comment

@duarteroso It's more on the parser's problem than vfmt (Can confirm that it does the same thing on the compiler). Thanks for reporting.

All 4 comments

@duarteroso It's more on the parser's problem than vfmt (Can confirm that it does the same thing on the compiler). Thanks for reporting.

Infinite looping has been prevented in 75b8822 (it does not check for the exact syntax that failed, but it should stop after 50 unsuccessful attempts to continue after .eof)

It now prints: sanity check while scanning

Fixed in newer versions of V:

testy.v:3:35: error: use `&Type` instead of `*Type` when declaring references
    1 | module main
    2 | 
    3 | type callback = fn (int,const char*[])
      |                                   ^

vfmt error while formatting file: testy.v .
Encountered a total of: 1 errors.
Was this page helpful?
0 / 5 - 0 ratings