You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Julia mode - deleting a parenthesis & typing a curly bracket causes stack overflow #6428
Delete all contents, type in a(){}(). (thanks to @fonsp for the MWE)
Delete the first paranthesis using backspace, then type {
Expected: typed character ('{') to appear.
Actual: Editor gets stuck, console shows:
codemirror.js:869 Uncaught RangeError: Maximum call stack size exceeded
at String.match (<anonymous>)
at StringStream.match (codemirror.js:869)
at Object.tokenCallOrDef [as tokenize] (julia.js:258)
at Object.tokenCallOrDef [as tokenize] (julia.js:292)
at Object.tokenCallOrDef [as tokenize] (julia.js:292)
at Object.tokenCallOrDef [as tokenize] (julia.js:292)
at Object.tokenCallOrDef [as tokenize] (julia.js:292)
at Object.tokenCallOrDef [as tokenize] (julia.js:292)
at Object.tokenCallOrDef [as tokenize] (julia.js:292)
at Object.tokenCallOrDef [as tokenize] (julia.js:292)
Now, I don't fully understand how that code works so my solution is probably incorrect (and hence not in a pull request), but here's a shot:
The infinite loop seems to happen in tokenCallOrDef. If none of the conditionals match, the function doesn't return but just calls itself with the same parameters. The following code checks whether no progress on parsing was made via the conditionals and if so returns control to tokenBase instead of calling again:
function tokenCallOrDef(stream, state) {
var previousPos = state.charsAdvanced;
var match = stream.match(/^(\(\s*)/);
if (match) {
if (state.firstParenPos < 0)
state.firstParenPos = state.scopes.length;
state.scopes.push('(');
state.charsAdvanced += match[1].length;
}
if (currentScope(state) == '(' && stream.match(/^\)/)) {
state.scopes.pop();
state.charsAdvanced += 1;
if (state.scopes.length <= state.firstParenPos) {
var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false);
stream.backUp(state.charsAdvanced);
state.firstParenPos = -1;
state.charsAdvanced = 0;
state.tokenize = tokenBase;
if (isDefinition)
return "def";
return "builtin";
}
}
// Unfortunately javascript does not support multiline strings, so we have
// to undo anything done upto here if a function call or definition splits
// over two or more lines.
if (stream.match(/^$/g, false)) {
stream.backUp(state.charsAdvanced);
while (state.scopes.length > state.firstParenPos)
state.scopes.pop();
state.firstParenPos = -1;
state.charsAdvanced = 0;
state.tokenize = tokenBase;
return "builtin";
}
state.charsAdvanced += stream.match(/^([^()]*)/)[1].length;
if (state.charsAdvanced == previousPos) {
// Couldn't make progress using any of the above so abort
state.tokenize = tokenBase;
return state.tokenize(stream, state);
}
return state.tokenize(stream, state);
}
Activity
Update/5.58.2 (#1)
[julia mode] Fix infinite recursion