Bug in javascript patch

psonice's picture

Just found an annoying bug in the javascript patch, this is on 10.5.2 but might affect older systems. So be warned, perhaps it'll save you a bit of head scratching.

Basically, the line length seems to be limited. I'm not sure if this affects all lines, but it definitely affects the line where you specify in/outputs for main. If your line is too long, it lets you type away but doesn't interpret past a certain point, resulting in an error telling you there's a mistake. (For me, it was saying that the main definition was invalid, or something like that).

The cure is to shorten your variable names - splitting it between multiple lines doesn't work (I guess it splits the code by ';' characters rather than new lines, but only alocates 256b for the line).

cwright's picture
256 bytes is enough for anyone!

man, that's lame. There's no end to the lameness with the JS patch I guess (all the parser hacks that are fragile, this bug, others....). Now I don't feel so bad about taking long on the JavaVM/Python patches.... :)

jean_pierre's picture
lame that the patch doesn't

lame that the patch doesn't work properly, did you file a bug?

psonice's picture
No, and now i can't reproduce it?!

Really strange! I just went to file the bug, and set up a basic js test case to include. I made a really long main() line, and it worked fine.

Perhaps there was something else wrong with my original script? I can't see how though, because all I did to fix it was shorten some of the variable names, and the errors were indicating that it was missing the ); at the end of the line. Shortening the variables made the missing ); errors disappear.

cwright's picture
spaces (not desktops ;)

I've seen some parser bugs in the JS patch if you include spaces in the function prototype line. There were some mailing list posts about this, but I can't seem to find them.

The gist of it was something like this:

function (__number outputNumber) main (__number inputNumber[2])

is not the same as

function (__number outputNumber ) main (__number inputNumber[2])

(note the space after outputNumber, before the closing parenthesis. Outputs won't properly get updated with the latter version. I'm not sure if similar things happen to inputs.

Perhaps you stumbled onto something similar?