mike-lischke / antlr4-c3

A grammar agnostic code completion engine for ANTLR4 based parsers
MIT License
396 stars 62 forks source link

symbolWithContextSync causing Maximum call stack size exceeded #117

Open jlchmura opened 3 months ago

jlchmura commented 3 months ago

Mike,

The call to getAllSymbolsSync on line 303 was causing a RangeError in one of my symbol tables. Shouldn't it have localOnly set to true? Unless I misunderstand this use of this function, if we're looking for a symbol tied to a specific context, why would that symbol be in a non-local table anyway?

https://github.com/mike-lischke/antlr4-c3/blob/c0530ed7e41911e734a5be75abf5d381589398b5/src/SymbolTable.ts#L303

mike-lischke commented 3 months ago

Yes, using only local symbols sounds reasonable. Did it solve your problem with that flag?

But even if it does, with deeply nested symbols this can always crash. Better would be to implement that as iteration (and exchange the duplicated local method code by a single implementation).

jlchmura commented 3 months ago

Using local only did solve the problem. Though you're correct, I do need to look into an iteration-based implementation because I do have deeply nested symbols and this is bound to pop up somewhere else.