You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit df024f4
Browse filesBrowse the repository at this point in the historyBrowse files
Check @notundefined of an interface against the implementation
Why:
Interface inclusion ignored `@notUndefined`. An interface could declare
`@notUndefined type t` over `type t = option<int>`, and clients then
unboxed `option<t>`, so `Some(M.none)` was `None` (#8964).
When the second declaration of an inclusion is `@notUndefined`, the first
must be a type that cannot hold `undefined`, by the rule `option` unboxing
uses, or an abstract type, which has no representation to contradict it.
This covers `.resi` files, functor arguments and `with type` constraints.
The check runs in `Includemod`, since `Typeopt` depends on `Includecore`
through `Typedecl`.
Diagnostic added:
Example:
// Hidden.resi
@notundefined type t
// Hidden.res
type t = option<int>
After (diagnostic):
Type declarations do not match:
type t = option<int>
is not included in
type t
Their runtime representations differ:
the second declaration is @notundefined,
but the first declaration can hold undefined.
Review: Why accept an abstract implementation without the attribute? The
stdlib's `Lazy.res` declares `type t<+'a>` under `@notUndefined` in its
interface, and so may bindings; such a type has no representation that could
hold `undefined`, so requiring the attribute twice would only break them.
Fixes: #8964
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fc7LEuyEfynjaKCVEBPmTF
Signed-off-by: Christoph Knittel <ck@cca.io>
- Reject an implementation that can hold `undefined` for a type its interface declares `@notUndefined`, which made `Some(None)` of the type `None` in clients.
0 commit comments