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

keyof - fix LUAU_ASSERT when there's only one key entry #1388

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

karl-police
Copy link
Contributor

@karl-police karl-police commented Sep 8, 2024

Fixes #1387

Was suggested by @alexmccord

I changed singletons[0] to singletons.front(), unsure if that makes a huge difference, and then I added the rest of the things needed for the return type.

Maybe it's also the ideal location since doing it before looping through keys won't add the string into the type arena.

I put comments next to it based on how I thought it would make sense.

 

LUAU_ASSERT seems to trigger when there's only one entry being put inside a UnionType. It's as if it was put there for quality.

Allow edits by maintainers is enabled.

I tested this with a quick Unit Test something like

local test: keyof<typeof({a="test"})>

@andyfriesen
Copy link
Collaborator

Thanks!

Could you add a unit test to TypeFunction.test.cpp?

@andyfriesen andyfriesen self-assigned this Sep 9, 2024
@karl-police
Copy link
Contributor Author

Thanks!

Could you add a unit test to TypeFunction.test.cpp?

will do in a bit

Fix an issue where LUAU_ASSERT would trigger if keyof was used on a table with one key entry. luau-lang#1387
@karl-police
Copy link
Contributor Author

Thanks!

Could you add a unit test to TypeFunction.test.cpp?

it has been done

@Vighnesh-V Vighnesh-V merged commit a8047b2 into luau-lang:master Sep 9, 2024
7 checks passed
@karl-police karl-police deleted the keyof_single_entry_fix branch September 13, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

keyof with one key index now triggers assert?
3 participants