Acknowledged

bug: compilation fails because of code inside removed has block

I get a compilation error:

ERROR: fenix5: AppView.mc:38,4: Could not find method onTimerEvent on object $.AppView

I don't think I am supposed to get. SDK: 7.4.3, device: fenix5 that doesn't support ActivityRecording.Session.setTimerEventListener , and this is my relevant part of the code:

(Sorry for the unformatted code, can't post code! see: https://forums.garmin.com/developer/connect-iq/f/discussion/389914/meta-forum-returning-lots-of-errors-today-e-g-parens-links-and-images-cause-problems )

and monkey.jungle:

project.optimization = 3z
fenix5.excludeAnnotations=$(fenix5.excludeAnnotations);session_timer_event_listener
When I remove the (:session_timer_event_listener) then it compiles, but why do I need to have an empty function just to be able to compile something that can be never called?
Note that the block for the has is correctly removed ("never called is not logged"). This is my command line for compilation:
java -Xms1g -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar ~/Library/Application Support/Garmin/ConnectIQ/Sdks/connectiq-sdk-mac-7.4.3-2024-12-11-90ec25e45/bin/monkeybrains.jar -o bin/App.prg -f App/monkey.jungle -y garmin/garmin_developer_key.der -d fenix5_sim -w
Parents
  • Anyway, is there any way to do this (without Prettier Monkey C)? I tried to add an empty function with (:base) annotation, but if course that is also removed too early. So the only way to compile this is either leaving there an empty function or create two versions of the initialize , one with (:session_timer_event_listener) and one with (:no_session_timer_event_listener) (but this needs further jungling (which in my case is not a big deal as my script automatically generates either of the excludeAnnotations based on the existence of a function in debug.xml (which technically helps me doing what the 7.x compiler should already do probably with the has check in compile time) but is a bit of a hassle if someone is editing the jungle manually)

Comment
  • Anyway, is there any way to do this (without Prettier Monkey C)? I tried to add an empty function with (:base) annotation, but if course that is also removed too early. So the only way to compile this is either leaving there an empty function or create two versions of the initialize , one with (:session_timer_event_listener) and one with (:no_session_timer_event_listener) (but this needs further jungling (which in my case is not a big deal as my script automatically generates either of the excludeAnnotations based on the existence of a function in debug.xml (which technically helps me doing what the 7.x compiler should already do probably with the has check in compile time) but is a bit of a hassle if someone is editing the jungle manually)

Children
  • The recommendation that was given by development was to take the following block of code and put it into a separate function that can be eliminated.

    if (ActivityRecording.Session has :setTimerEventListener) {
          System.println("never called");
          session.setTimerEventListener(method(:onTimerEvent)); // error in this line
    }