Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current string interpolation codegen can cause exponential runoff in certain Lua parsers #1463

Open
lizreu opened this issue Jul 2, 2023 · 0 comments
Labels
optimization scope: transformation Transformation of TS to Lua

Comments

@lizreu
Copy link

lizreu commented Jul 2, 2023

This isn't an issue with any Lua interpreters that I know of, but libraries implementing Lua parsers (especially PEG) really struggle parsing expressions of the following form:
return (((((((((((((((("a" .. a) .. ",") .. b) .. ",") .. c) .. ",") .. d) .. ",") .. e) .. ",") .. f) .. ",") .. g) .. ",") .. h) .. ",") .. i

This is the output of something like a{a},{b},{c},{d},..

While this is trivial to fix in controlled code by not using string interpolation for very long expression, it is not trivial to fix in certain parser architectures, and impossible to guard against "in the wild".

Here is an example of a Lua parser that gets tripped up by this: Kampfkarren/full-moon#279

This -should- be straightforward to fix by flattening out the nested expression, and simply emitting "a" .. a .. "," .. b .. "," ..

@Perryvw Perryvw added optimization scope: transformation Transformation of TS to Lua labels Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization scope: transformation Transformation of TS to Lua
Projects
None yet
Development

No branches or pull requests

2 participants