WARNING: jsvGetString Overflowed

Posted on
  • Hi All,

    My code is using and unique ID for messages that is randomly generated (say: acbdefghijklmnopqrstuvwxyz1234567890). If I put those IDs in an object and run hasOwnProperty on the object to look for the ID, it returns a WARNING: jsvGetString Overflowed.

    this example shows the bug:

    function foo() {
      var bar= {"acbdefghijklmnopqrstuvwxyz1234567890":­2};
      console.log(bar, bar.hasOwnProperty("acbdefghijklmnopqrst­uvwxyz1234567890"));
    }
    
    function onInit() {
      foo();
    }
    

    Is this a bug or a limitation of the hardware?

    Regards,

    Alex

  • It's a bug - I'll file an issue for it. The length of IDs in Espruino is limited - but that should only be for things like function names.

    The problem is when Espruino tries to check all of the built-in methods as well.

    For now, I'd recommend that you just use in:

    function foo() {
      var bar= {"acbdefghijklmnopqrstuvwxyz1234567890":­2};
      console.log(bar, "acbdefghijklmnopqrstuvwxyz1234567890" in bar);             
    }
    
  • Hi Gordon,

    thank you for the reply :). I've sidestepped the issue for now by using a large random number and toString(36) with it. Is it a better practice in general to check if a key exists with "in" instead of "hasOwnProperty"? Is this both the case for normal javascript as well as espruino?

    Regards,

    Alex

  • I can't really comment on normal JS I'm afraid. In Espruino, using in is probably marginally faster though, and you could argue it's more readable...

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

WARNING: jsvGetString Overflowed

Posted by Avatar for Alex @Alex

Actions