darklua icon indicating copy to clipboard operation
darklua copied to clipboard

Specify `LuaVersion` when parsing with `full_moon`

Open jiwonz opened this issue 9 months ago • 1 comments

If you are depending on darklua and full_moon in a root project, and you add features that are incompatible with luau, such as lua53, to full_moon's features, the features will be combined due to the cargo's characteristics of deduplicating shared dependencies (perhaps full_moon is now shared and reused in the relationship between darklua's dependencies and the root project's dependencies). This can cause several incompatibilities and parsing problems, such as this issue.

Therefore, I think this problem can be solved by specifying the specific LuaVersion parameter of full_moon::parse_fallible, which has been available since full_moon v1.0.0, and explicitly parsing it as LuaVersion::Luau in darklua.

jiwonz avatar Mar 13 '25 09:03 jiwonz

Just found full_moon::parse(code) is just equivalent to full_moon::parse_fallible(code, LuaVersion::new()).into_result() Image https://docs.rs/full_moon/latest/src/full_moon/lib.rs.html#92-94

And I think this is what causes the issue: Image https://docs.rs/full_moon/latest/full_moon/ast/struct.LuaVersion.html#method.new

It seems it's simple to migrate full_moon::parse into full_moon::parse_fallible for Lua version specifying

jiwonz avatar Mar 13 '25 12:03 jiwonz