Skip to content

Conversation

@Kamirus
Copy link
Contributor

@Kamirus Kamirus commented Nov 24, 2025

Joining two unrelated types (using glb or lub) is not an immediate error, just results in Non or Any.
This can lead to loosing type information in errors, example:
Non <: T <: Any starting point
Nat <: T <: Any glb with Nat
Any <: T <: Any glb with Text, we lost info about Nat and Text
Now, lub with Float fails with an over-constrained error, but at this point we only know that T := Any which is not helpful.

This PR adds tracking of 'failed' glb/lub by checking whether their result the the appropriate extreme and adds this extra error info to the error message.
Here it would say 'T' inferred to 'Nat' but incompatible with 'Text'

However, this PR is not that helpful in common cases where our current error handling is enough.
So I'm not sure if the extra complexity is worth it.

@github-actions
Copy link
Contributor

Comparing from bfc6838 to 2d9429d:
The produced WebAssembly code seems to be completely unchanged.
In terms of gas, no changes are observed in 5 tests.
In terms of size, no changes are observed in 5 tests.

Bool
because there is no way to satisfy subtyping
Bool <: T (for argument `x`)
`T` inferred to `Int` but incompatible with `()`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the () coming from, the return type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the return type yes

[var Nat]
because there is no way to satisfy subtyping
[var Nat] <: [var T] (for argument `x`)
`T` inferred to `()` but incompatible with `Nat`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@crusso
Copy link
Contributor

crusso commented Nov 24, 2025

Maybe not worth the complexity?

Base automatically changed from kamil/short-bimatch-arg-ret-errors to master December 1, 2025 17:08
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.

3 participants