1lab/mikan
13
52
Fork
You've already forked mikan
9

CantResolveOverloadedConstructorsTargetingSameDatatype sometimes worse than useless #104

Open
opened 2026年05月15日 18:30:36 +02:00 by amyliao · 0 comments

This error (with a very concise name) is given when disambiguation can't decide between distinct copies of a constructor because the expected type of the pattern is underconstrained, meaning we can't compare the types of the copies. The error message doesn't mention this at all - only the name of the expected datatype and of all possible constructors, even the ones that were positively ruled out. For example:

dataBool:Setwheretruefalse:BoolmoduleFoo(b:Bool)wheredataD:Setwherec:DopenmoduleTrue=FootrueopenmoduleFalse=FoofalsedataConfuse:Setwherec:Confusetest:Foo.D?Settestc=?-- error: [CantResolveOverloadedConstructorsTargetingSameDatatype]-- Can't resolve overloaded constructors targeting the same datatype-- (Test495.Foo.D): Test495.True.c Test495.False.c Test495.Confuse.c

The error is thrown in two places:

I think a better error message would be something like:

Can't disambiguate between constructors for type Foo.D ?
Possible candidates:
 * Test495.True.c : True.Foo
 * Test495.False.c : False.Foo

The new type for the error should then be:

|CantResolveOverloadedConstructorsTargetingSameDatatypeType-- ^ Expected type at position(List1(QName,Type,MaybeTCState))-- ^ Resolved constructor name, its return type, and possibly the new TC state-- The type must be @prettyTCMCtx TopCtx@ /in the new state/ if given, but the-- resulting @Doc@ is freely movable.

Note that the QName in the dcs' list in Application.hs is not the name of the constructor. You want conName from the ConHead instead.

This error (with a very concise name) is given when disambiguation can't decide between distinct *copies* of a constructor because the expected type of the pattern is underconstrained, meaning we can't compare the types of the copies. The error message doesn't mention this at all - only the *name* of the expected datatype and of *all possible* constructors, even the ones that were positively ruled out. For example: ```agda data Bool : Set where true false : Bool module Foo (b : Bool) where data D : Set where c : D open module True = Foo true open module False = Foo false data Confuse : Set where c : Confuse test : Foo.D ? → Set test c = ? -- error: [CantResolveOverloadedConstructorsTargetingSameDatatype] -- Can't resolve overloaded constructors targeting the same datatype -- (Test495.Foo.D): Test495.True.c Test495.False.c Test495.Confuse.c ``` The error is thrown in two places: * https://codeberg.org/1lab/mikan/src/commit/f56118785f5e78eca5592a7601a6f547353b8a06/src/full/Mikan/TypeChecking/Rules/LHS.hs#L1757 * https://codeberg.org/1lab/mikan/src/commit/f56118785f5e78eca5592a7601a6f547353b8a06/src/full/Mikan/TypeChecking/Rules/Application.hs#L1088-L1090 I think a better error message would be something like: ``` Can't disambiguate between constructors for type Foo.D ? Possible candidates: * Test495.True.c : True.Foo * Test495.False.c : False.Foo ``` The new type for the error should then be: ```agda | CantResolveOverloadedConstructorsTargetingSameDatatype Type -- ^ Expected type at position (List1 (QName, Type, Maybe TCState)) -- ^ Resolved constructor name, its return type, and possibly the new TC state -- The type must be @prettyTCMCtx TopCtx@ /in the new state/ if given, but the -- resulting @Doc@ is freely movable. ``` Note that the `QName` in the `dcs'` list in `Application.hs` is *not* the name of the constructor. You want `conName` from the `ConHead` instead.
Sign in to join this conversation.
No Branch/Tag specified
main
aliao/occurs-opt
aliao/rec-con
fix-license
aliao/oopsie
aliao/strengthen-iapply
No results found.
Labels
Clear labels
1 - scope
language
Backwards-compatible changes to the surface language, such as adding new features.
1 - scope
language change
Breaking changes to a documented part of the surface language. These should be documented and specifically called out in the changelog.
1 - scope
performance
Semantics-preserving performance work.
1 - scope
task
Changes that are not apparent to the user, e.g. developer documentation and refactors, which do not need to be documented.
A: dead-code
Dead code elimination and --save-metas.
A: errors
Reporting of error and warning messages.
A: highlighting
Highlighting during interaction & literate compilation
A: imports
Handling of imports and interface file de/serialization.
A: infra
Iinfrastructure (e.g. CI, developer documentation, the build system, or the repository itself)
A: instance
Instance declarations, arguments, and resolution
A: lhs
LHS checking, coverage checking, and clause compilation
A: modules
Declaration and instantiation of parametrised modules.
A: parallel
Parallel typechecking.
A: positivity
Positivity checking
A: printing
Pretty-printing, display forms, and the wording of diagnostic messages
A: records
Record declarations, record expressions and copattern matching
A: scoping
Scope checking (ConcreteToAbstract)
A: termination
Termination checking
0 - type
bug
Issues describing an incorrect behaviour in the project, typos in the documentation, etc.
0 - type
discussion
An issue raised to gather opinions on a proposed change, or a suggested language change.
0 - type
question
An issue raised to ask a question.
9 - status
duplicate
This issue or pull request already exists.
9 - status
info needed
More information is needed from the submitter to decide how to proceed with the issue report.
9 - status
invalid
The issue report or pull request does not describe an actual bug, or does otherwise does not meet the contributing guidelines.
good first issue
Interested in contributing? Get started here.
upstream
Related to an upstream repository, already reported there
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
1lab/mikan#104
Reference in a new issue
1lab/mikan
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?