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

Application of 'remove_types' can change runtime behavior where a function call has a type assertion #140

Closed
sircfenner opened this issue Nov 2, 2023 · 1 comment · Fixed by #142

Comments

@sircfenner
Copy link

Adding a type assertion to a function call has the (runtime) effect of truncating any returned values to a maximum of one value:

local function multipleReturns()
    return 1, 2
end
print(multipleReturns() :: any)

This will output "1".

Currently, the 'remove_types' rule translates line 4 as:

print(multipleReturns())

This will output both "1" and "2", incorrectly.

The 'remove_types' rule should wrap these type-asserted calls in parentheses:

print((multipleReturns()))

This will output "1", correctly.

@jeparlefrancais
Copy link
Contributor

Good catch! This should be a simple fix, I already have this kind of verification in other parts of darklua

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 a pull request may close this issue.

2 participants