luau-lang / luau

A fast, small, safe, gradually typed embeddable scripting language derived from Lua
https://luau.org
MIT License
3.98k stars 373 forks source link

Underflow for column count in luau-analyze involving a syntax and return type error in function #1327

Open nothing1649 opened 2 months ago

nothing1649 commented 2 months ago

As of release 0.634, the following code (with a newline at the end of it) causes the column count in luau-analyze to underflow:

local function _test(): boolean
    if true then
    -- end
end --newline after here

This causes luau-analyze to report the following:

.\underflow.luau(5,1): SyntaxError: Expected 'end' (to close 'function' at line 1), got <eof>; did you forget to close 'then' at line 2?
.\underflow.luau(5,-2): TypeError: Not all codepaths in this function return 'boolean'.

I'm unsure of how to attach the .luau file to a github report however it appears to reproduce with the most recent (as of writing) luau-windows.zip download.