Announcement

Collapse
No announcement yet.

Monkey C compiler: Undefined symbol detection is inconsistent

Collapse
X
  • Time
  • Show
Clear All
new posts

  • Monkey C compiler: Undefined symbol detection is inconsistent

    The undefined symbol detection in the Monkey C is compiler is great and a very welcome feature. However, I have noticed that some missing symbols are detected while others are not. I realize that some omissions may be purposeful, to avoid breaking certain types of existing code, but perhaps in those cases the compiler could emit a warning instead of an error?

    Environment: CIQ SDK 3.0.7

    In the following code, assume that A is an undefined symbol.
    Code:
        function initialize() {
            SimpleDataField.initialize();
    
            var x = new A(); // produces compile error as expected
            A(); // compiles but crashes at run time
            A = null; // compiles but crashes at run time
            // ...
        }

  • #2
    Hi FlowState , I tested the sample code that you provided - all three lines of code resulted in a compiler error for me using the 3.0.7 SDK. Is it possible that you were using an older SDK? Could you possibly provide the code you are testing with and I can test that directly?

    Comment


    • #3
      Marianne.ConnectIQ Thanks for following up. I am using the latest SDK, 3.0.7.

      Sorry, I stupidly edited my test case to make it look better, by changing lowercase "a" to uppercase "A". Turns out that has something to do with it. Here's an updated test case, including an example where it failed for me in my real app (and caused a crash in real life).

      Uncomment a test case to see the noted behaviour. Assume that "A", "a", "x" and "power" are all undefined.
      Code:
      var obj;        
      
      //obj = new A(); // Compiler error: Undefined symbol "A" detected.
      //A();           // Compiler error: Undefined symbol "A" detected.
      //A = null;      // Compiler error: Undefined symbol "A" detected.
      
      //obj = new a(); // Compiler error: Invalid symbol "a" used in the context of a new object instantiation. No class exists with the given symbol name.
      //a();           // Compiler error: Invalid symbol "a" used in the context of a function invocation. No function exists with the given symbol name.
      //a = null;      // Runtime error: Could not find symbol a. Symbol Not Found Error
      
      //obj = new x(); // Runtime error: Could not find symbol x. Symbol Not Found Error
      //x();           // Compiler error: Invalid symbol "x" used in the context of a function invocation. No function exists with the given symbol name.
      //x = null;      // Runtime error: Could not find symbol x. Symbol Not Found Error
      
      //obj = new power(); // Runtime error: Could not find symbol power. Symbol Not Found Error
      //power();           // Compiler error: Invalid symbol "power" used in the context of a function invocation. No function exists with the given symbol name.
      //power = null;      // Runtime error: Could not find symbol power. Symbol Not Found Error
      The last case of "power = null" is a real crash that a user saw in my real app in the store, due to an undefined symbol. (Typo/copy-paste error.)
      Last edited by FlowState; Yesterday, 11:47 AM.

      Comment

      Working...
      X