Skip to content

Make untyped not match any other type#292

Merged
mame merged 1 commit intomasterfrom
change-untyped
Mar 5, 2025
Merged

Make untyped not match any other type#292
mame merged 1 commit intomasterfrom
change-untyped

Conversation

@mame
Copy link
Member

@mame mame commented Feb 28, 2025

So far, we have assumed that untyped matches any type. This approach had a problem that when an argument is untyped, it matches a method signature, and when the argument is any concrete type, it does not match the same method signature, and if the result of the match affects the type of the argument itself, the analysis would oscillate and loop endlessly.

This change makes untyped not match any other type. This will have a significant difference from gradutal typing's untyped (or any). Instead, we suppress diagnostics like expected: C, actual: untyped. We expect that this will not make much difference on the user side.

By assuming that untyped does not match a concrete type, it is expected that the scope of analysis will be narrower (not enough analysis can be done after the method call that fails to resolve overload). Therefore, we decided that if there is no overload in the method signature, the method signature will always be chosen (errors will be reported if there is a discrepancy in the type or number of arguments). This is expected to allow many method calls to be parsed with concrete types afterwards, even if there are discrepancies in arguments.

@mame mame force-pushed the change-untyped branch from 9037efc to be028a7 Compare March 5, 2025 09:03
@mame mame enabled auto-merge (rebase) March 5, 2025 09:03
So far, we have assumed that `untyped` matches any type. This approach
had a problem that when an argument is untyped, it matches a method
signature, and when the argument is any concrete type, it does not match
the same method signature, and if the result of the match affects the
type of the argument itself, the analysis would oscillate and loop
endlessly.

This change makes `untyped` not match any other type. This will have a
significant difference from gradutal typing's `untyped` (or `any`).
Instead, we suppress diagnostics like `expected: C, actual: untyped`.
We expect that this will not make much difference on the user side.

By assuming that untyped does not match a concrete type, it is expected
that the scope of analysis will be narrower (not enough analysis can be
done after the method call that fails to resolve overload).
Therefore, we decided that if there is no overload in the method
signature, the method signature will always be chosen (errors will be
reported if there is a discrepancy in the type or number of arguments).
This is expected to allow many method calls to be parsed with concrete
types afterwards, even if there are discrepancies in arguments.
@mame mame force-pushed the change-untyped branch from be028a7 to 46ec526 Compare March 5, 2025 09:06
@mame mame merged commit 1a933d6 into master Mar 5, 2025
14 checks passed
@mame mame deleted the change-untyped branch March 5, 2025 09:07
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