ZenCodeLang / ZenCode

The ZenCode project.
MIT License
12 stars 8 forks source link

Result `unwrap` cannot find field "java.lang.NoSuchFieldError: field0" #117

Open jaredlll08 opened 10 months ago

jaredlll08 commented 10 months ago

Due to the generic bound on E (<T, E : Exception>), when the bytecode is written, it is written as:

GETFIELD stdlib/Result$Error.field0 : Ljava/lang/Exception;

Which cannot be found as it is declared as:

  // access flags 0x11
  // signature TE;
  // declaration: field0 extends E
  public final Ljava/lang/Object; field0

Repro:

import stdlib.Result;
import stdlib.Exception;

Result<string, Exception>.Error(new Exception("Errored")).unwrap();
kindlich commented 2 months ago

Should be fixed by #158, let's test this with variants again once that PR is merged.