Simn / genjvm

13 stars 1 forks source link

VerifyError: Method expects a return value #27

Closed nadako closed 5 years ago

nadako commented 5 years ago
class Main {
    static function main() {
        f();
    }

    static function f():Int {
        while (true) {
            // throw "oops";
            return 1;
        }
    }
}
  public static int f();
    Code:
       0: iconst_1
       1: ifeq          6
       4: iconst_1
       5: ireturn
       6: return

looks like we always add a final return in cases like this, but we really should generate a proper instruction based on the return type

nadako commented 5 years ago

we really should generate a proper instruction based on the return type

or we should optimistically not generate the final return at all?

nadako commented 5 years ago

PS this was extracted from haxe.format.JsonParser.parseRec.

Simn commented 5 years ago

We have to avoid both the return and the ifeq in this situation.