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

Feature: multiple type errors #122

Merged
amyliao merged 4 commits from aliao/defer-type-errors into main 2026年06月10日 21:56:11 +02:00

(This PR is basically ready to review on top of #121, but I do want to write a bit more haddock and factor out some common patterns.)

The refactoring in #121, which makes it possible to catch a TypeError and cram the contained diagnostic into a TCWarning, makes it almost comically easy to recover from arbitrary type errors in checkExpr; see deferError. There's a bit of finagling to preserve the Call of the original error but the implementation is basically

deferErrors :: Type -> TCM Term -> TCM Term
deferErrors wanted check = check `catch` \err -> do
 warning err
 snd <$> newValueMeta wanted

The headline test case is MultipleErrors:

9e6aea7dbb/test/Fail/MultipleErrors.err (L1-L14)

The cost of this is that the "automatically jump to errors" thing in the interaction point was found dead in a ditch: the most common class of errors is no longer caught by the handleCommand handler which called tellEmacsToJumpToError. I would like to believe that this is probably a misfeature anyway and we can support a "go to the next error" explicit command instead.

(This PR is basically ready to review on top of #121, but I do want to write a bit more haddock and factor out some common patterns.) The refactoring in #121, which makes it possible to catch a `TypeError` and cram the contained diagnostic into a `TCWarning`, makes it almost comically easy to recover from arbitrary type errors in `checkExpr`; see `deferError`. There's a bit of finagling to preserve the `Call` of the original error but the implementation is *basically* ```haskell deferErrors :: Type -> TCM Term -> TCM Term deferErrors wanted check = check `catch` \err -> do warning err snd <$> newValueMeta wanted ``` The headline test case is `MultipleErrors`: https://codeberg.org/1lab/mikan/src/commit/9e6aea7dbb095a287875222057789e2cb347c9b2/test/Fail/MultipleErrors.err#L1-L14 The cost of this is that the "automatically jump to errors" thing in the interaction point was found dead in a ditch: the most common class of errors is no longer caught by the `handleCommand` handler which called `tellEmacsToJumpToError`. I would like to believe that this is probably a misfeature anyway and we can support a "go to the next error" explicit command instead.
amyliao 2026年05月28日 04:08:35 +02:00
Contributor
Copy link

fwiw as an editor integration author i think the 'automatic jump to error' thing is no good and we should be like a normal language that lets you cycle through diagnostics, errors and warnings

fwiw as an editor integration author i think the 'automatic jump to error' thing is no good and we should be like a normal language that lets you cycle through diagnostics, errors and warnings
Author
Owner
Copy link

Yeah, it would be easy enough to include the ranges of all reported diagnostics as structured data in addition to those in the printed forms (that you can, at least in emacs, click on to go to)... something to consider for #17, I guess.

Yeah, it would be easy enough to include the ranges of all reported diagnostics as structured data in addition to those in the printed forms (that you can, at least in emacs, click on to go to)... something to consider for #17, I guess.
amyliao force-pushed aliao/defer-type-errors from 9e6aea7dbb
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
to 5e9b3282e2
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
2026年06月01日 14:37:03 +02:00
Compare
amyliao force-pushed aliao/defer-type-errors from 5e9b3282e2
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
to b6e19ee176
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
2026年06月02日 12:50:17 +02:00
Compare
amyliao force-pushed aliao/defer-type-errors from 99e2ef28ef
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
to 1424d5b4e7
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
2026年06月04日 00:45:06 +02:00
Compare
amyliao force-pushed aliao/defer-type-errors from 1424d5b4e7
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
to c8d9933021
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
2026年06月04日 14:34:37 +02:00
Compare
fix: instance filtering on checkTerm wake-ups
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
817c0094ce
The simplified error message in `Issue3676` was actually a symptom of
breakage that manifested in Cat.Site.Grothendieck, minimised into
InstanceDeferredErrors: since instance candidates are selected/rejected
based on whether equating their type with the type of the goal succeeds
(which can result in a definite negative result if this wakes up
existing constraints into failures), the control flow of instance
selection depends on woken up Unblock (PostponedTypecheckingProblem)
constraints raising hard errors.
amyliao changed target branch from aliao/diagnostic-class to main 2026年06月05日 14:32:19 +02:00
fix: jump to errors in the source module
Some checks failed
ci/woodpecker/pr/test Pipeline was canceled
971f9232b8
The `agda2-maybe-goto` thing is likely going away entirely soon but in
the meantime it is possible to preserve this bit of behaviour.
amyliao force-pushed aliao/defer-type-errors from 971f9232b8
Some checks failed
ci/woodpecker/pr/test Pipeline was canceled
to e5e5bedc20
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/push/main Pipeline was successful
2026年06月09日 19:55:21 +02:00
Compare
amyliao deleted branch aliao/defer-type-errors 2026年06月10日 21:56:14 +02:00
Sign in to join this conversation.
No reviewers
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
3 participants
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!122
Reference in a new issue
1lab/mikan
No description provided.
Delete branch "aliao/defer-type-errors"

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?