Acknowledged
over 1 year ago

Compiler crashes when type check is enabled

When compiling my app (available here https://github.com/matco/badminton) with type check enabled (parameter -l set to 1, 2 or 3), the compiler crashes with the following error:

ERROR: class com.garmin.monkeybrains.compiler2.ir.expressions.ModuleAccess cannot be cast to class com.garmin.monkeybrains.compiler2.ir.values.PrimitiveValue (com.garmin.monkeybrains.compiler2.ir.expressions.ModuleAccess and com.garmin.monkeybrains.compiler2.ir.values.PrimitiveValue are in unnamed module of loader 'app')

The same app compiles perfectly when type check is disabled.

Steps to reproduce: 

  • Clone my app locally with git clone https://github.com/matco/badminton.git
  • Checkout one commit that triggers the error git checkout 44030067ea145b7952b050527a7a4474aaaead1e
  • Compile the app with java.exe -Xms1g -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar monkeybrains.jar -o bin/badminton.prg -f monkey.jungle -y developer_key -d fenix7_sim -w -l 1
  • It seems I can no longer edit the issue... So here is some additional information (thanks to FlowState):

    • It's better to checkout commit b3c9c40866486ce5c7c0170bccaebecdfb5a4de4
    • Compile it with SDK 6.2.2, it works!
    • Try with SDK 6.3.1 and you get the error
  • Thanks for this information. I will update the description of the bug accordingly. I also updated my code, so it can compile with the SDK version 6.2.2 with the type check mode set to 3.

  • > while still having types enabled

    uh, I mean while still having *type checking* enabled

  • I think this is a regression in SDK 6.3.0.

    If I compile with 6.3.0 (or 6.3.1), I get the error in the OP.

    If I compile with 6.2.2 (the latest pre-6.3.0 SDK), I get the following the errors:

    ERROR: descentmk2: ...\badminton\source\views\MatchView.mc:152,3: Cannot find symbol ':ANIMATION_TIME' on class definition '$.MatchView'.
    ERROR: descentmk2: ...badminton\source\views\MatchView.mc:163,8: Cannot find symbol ':ANIMATION_TIME' on class definition '$.MatchView'.

    I found that I can make the error go away with the following change:

    > git diff
    diff --git a/source/views/MatchView.mc b/source/views/MatchView.mc
    index 0cfa6ef..e980eb6 100644
    --- a/source/views/MatchView.mc
    +++ b/source/views/MatchView.mc
    @@ -243,7 +243,7 @@ class MatchView extends WatchUi.View {   

            const REFRESH_TIME_ANIMATION = 50;
            const REFRESH_TIME_STANDARD = 1000;
    -       const ANIMATION_TIME = 800;
    +       static const ANIMATION_TIME = 800;

            public var boundaries as MatchBoundaries?;

    I agree that Garmin should fix this problem, but hopefully this will allow you to move forward with your project while still having types enabled

  • The point is, the compiler crashes with only this error. It does not print the file, neither the line to understand the problem. The compiler should not crash like this, even if there is something wrong in my code.

    It happened after I added types in my code, and I will not spend hours removing types one by one to try to provide a minimal reproducible example, when Garmin can easily find out the cause.