Compiled code and related error messages

Posted on
  • function lenc(m) {
     "compiled";
      var l = m.length(m);
      return l;
    }
    function len() {
      var m = "123.456";
      console.log(lenc());
    }
    

    with len() entered/run in console complains:

     1v80 Copyright 2015 G.Williams
    >echo(0);
    =undefined
    >len()
    undefined
    =undefined
    Uncaught Error: Expecting a function to call, got Number
     at line 3 col 21
      console.log(lenc(m));
                         ^
    in function "len" called from line 1 col 5
    len()
         ^
    > 
    

    I know that it should read var l = m.length; in lenc()... but I got there only after a while when my mind had let go of the deceipt by the error message and I took a closer look at lenc().

  • Try to use the webide option 'Throttle send'...

  • Hi allObjects, try this ;-)

    function lenc(m) {
      "compiled";
      var l = m.length; //length without (), it is not a function
      return l;
    }
    function len() {
      var m = "123.456";
      console.log(lenc(m)); //add m to call
    }
    
  • I posted this because to make user's aware of the fact that error messages caused in compiled code dont reference the compiled code. The reference points to the 'last' layer of interpreted code.

    The error message is also different when invoking from with in an function o r invoking from the console directly:

    • Error message created on invocation of compiled code within a function().

      >len();
      undefined
      =undefined
      Uncaught Error: Function not found!
      at line 3 col 20
      console.log(lenc());
                      ^
      in function "len" called from line 1 col 5
      len();
       ^
      > 
      
    • Error message created on diret invocation of compiled code from console.

      >lenc("abc");
      =undefined
      Uncaught Error: Expecting a function to call, got Number
      at line 1 col 11
      lenc("123.456");
             ^
      > 
      
  • Thank's for sharing this. I had some problems with compiled code recently and @Gordon corrected the web ide... You should check that you have the last version. Furthermore I think that the compiled code can't effectively be debuged or interrupted from the command line. So you should check the dedicated page to compiling... Might have been obvious to you of course. :-)

  • ...compilation at upload to the board dit not complain... how could it. Therefore:

    There is always a first time surprise... and it may not be the last... no even the last of the same subject! ;-)

  • Thanks for posting up - Yes, the error message is a bit confusing. I guess some explanation on the Compiler page might help...

    Although it does say to write you code without "compiled" first and check it works ;) In that case it would have pointed to the correct point when the error occurred.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Compiled code and related error messages

Posted by Avatar for allObjects @allObjects

Actions