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

test disabling generic matches to empty containers except @[] #24397

Draft
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Nov 1, 2024

No description provided.

@metagn
Copy link
Collaborator Author

metagn commented Nov 1, 2024

More or less correct (except untyped/typed failing and const arr = [] still working) but not the right solution. Fixes #23496 but not #23199 or #23534.

The right solution is to whitelist empty containers in specific contexts like #22716, specifically:

  • As arguments to untyped/typed parameters
  • As arguments to parameters, given they receive a concrete type when the match is over (match to the parameter, not the entire call, though we could maybe support this in the future so that if nil == X crashes the compiler #23534 actually compiles instead of just giving a legible error)
  • [] as an argument to the seq overload of @
  • In any context where type inference can be performed after the expression is compiled, as long as the type is re-checked for a concrete value. So (@[], 1) compiles if it's a variable initializer with an annotated type, but not as a call argument.

Sounds nice in principle but a fair bit of a refactor if we also include things like uninstantiated routines and maybe there are cases where the codegen depends on empty types. And there is stuff like typeof(@[]) etc.

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.

1 participant