Sublime Forum

JavaScript - Highlight stops at 61th nested level

#1

I’ve noticed that Sublime doesn’t support more that 61 nested levels of code. Here is an example of JavaScript object which has 62 nested objects. The last a property is not highlighted at all (and if I add more nested objects, they stay black). You can see it here. I am posting here the actual code:

+{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{'a':{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}};

If I add, for example, 100 nested objects, everything after 61th is not highlighted, as you can see here. Is something wrong with my Sublime preferences, or is it really a bug. If maximal nested level can be manually modified somewhere in options, where I can found more info about it?

0 Likes

#2

This is most likely a side effect of the current implementation used for scope name specificity checking. I believe we are using a 64-bit int as a bit flag, with a bit used for sign and a couple for other purposes. It isn’t something you can configure.

2 Likes

#3

Would you mind telling where you encountered this issue? I find it rather unusual to have 60+ nested objects in some JavaScript code.

0 Likes

#4

I agree, even the biggest JavaScript project I was working on required only 50 nested levels (not only objects, but also function scopes, if statements etc…). But, recently I started learning Tensorflow. I created recurrent neural network and I fed a few thousands of JavaScript files in it (from Github), as I explained in my previous post.

So, neural net can now generate arbitrary long fully correct ES7 syntax JavaScript source file. This way I found a lot of issues, not only with Sublime, but also with almost any code highlighter, even Chrome console highlighter had an issue. Some of issues I’ve found: Division issue, Regex issue, String issue, Object issue, Mantissa issue, Constant declaration bug and a lot more. This is an example JavaScript file generated by RNN (I restricted it from using variable and function declarations in this example to avoid unnecessary reference errors).

1 Like

#5

Seems like a good test file. Not for automated testing though, that would be way too much, but nice for checking if syntax highlighting breaks at some point or whether it properly highlights certain tokens.

0 Likes