Skip to content

Error when using null or undefined in array literal#1223

Merged
Perryvw merged 2 commits intomasterfrom
undefined-in-array-literal
Mar 10, 2022
Merged

Error when using null or undefined in array literal#1223
Perryvw merged 2 commits intomasterfrom
undefined-in-array-literal

Conversation

@Perryvw
Copy link
Copy Markdown
Member

@Perryvw Perryvw commented Mar 5, 2022

Array literals containing null or undefined will lead to possibly broken Lua.

For instance:

const mytuple = [1, undefined, 3];

Will translate into:

local mytuple = {1, nil, 3}; -- Stops after first nil, this ends up being {1}

Added a warning to prevent users from doing this. Using null or undefined at the end of an array literal is still allowed.

Closes #1216

@Perryvw Perryvw requested review from lolleko and tomblind March 6, 2022 12:25
@Perryvw Perryvw merged commit 5d66aa4 into master Mar 10, 2022
@Perryvw Perryvw deleted the undefined-in-array-literal branch March 10, 2022 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TSTL should prevent compilation with tuples that contain undefined

1 participant