Unreachable code throws an error

Issue #31 wontfix
Fabian Maurer created an issue

Unreachable code like

function test()
    say "unknown", "hi";
    return true;
    say "unknown", "hi again";
end

throws an error like this:

mismatched input 'say' expecting 'end'

Though it would be nice to have unreachable code, so one could insert an early return for debugging purposes.

Comments (1)

  1. Chimaine

    I agree that the error message should make it more clear that this is about unreachable/dead code. I will put that on my todo list.

    However, there are two paradigms in programming languages out there how dead code should be handled. Some allow it, most don't. All languages I use do not, and this includes Lua. So we'll continue to throw an error if we want to compile obvious dead code.

  2. Log in to comment