hugowangler / D7050E

Building a compiler in Rust using LALRPOP for generating the parsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Interpreter panics on unreachable code due to return

hugowangler opened this issue · comments

When the interpreter gets an input containing a return statement followed by other statements it panics. This shouldn't happen since a program containing unreachable code should still be able to run.

ex:

fn test() -> i32 {
    return true;
    if (true) {
        return false;
    }
}

Can be solved by adding a next field to return. This part of the function will never be interpreted but it won't panic.