Kampfkarren / full-moon

A lossless Lua 5.1 parser
Mozilla Public License 2.0
379 stars 49 forks source link

Fix including trivia in check for typeof identifier #317

Closed YetAnotherClown closed 3 days ago

YetAnotherClown commented 6 days ago

Fixes #314

The following case will fail to parse correctly because the check at this line includes all trivia. When including the trivia, we end up with a check that looks like " typeof" = "typeof", which of course fails.

type T =
    typeof({})

This PR turns the token into a string instead of the token reference in the check, as the token does not contain trivia.

YetAnotherClown commented 3 days ago

@JohnnyMorganz The tests should be all good now, I had forgot to update ast.snap as well after fixing the tokens.snap, sorry about that!