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

Turn "missing with-clauses" into a warning? #124

Open
opened 2026年05月28日 15:21:58 +02:00 by jeanas · 2 comments

This is an error:

data Bool : Set where
 true false : Bool
foo : (Bool → Bool) → Bool → Bool
foo f x with f x

This is only a warning:

data Bool : Set where
 true false : Bool
foo : (Bool → Bool) → Bool → Bool
foo f x with f x
foo f x | true = false

Why?

It very often happens to me that I start writing a complicated expression to pattern match on, so I write with ..., and I want to verify that this type-checks before starting to write the further clauses, so I instinctively press C-c C-l, and syntax highlighting suddenly disappears from my whole file. In those cases, I add a clause like foo f x | _ = ? just to make Agda stop complaining and let me use the hole system to interactively build up the scrutinee after with. (I've barely tried Mikan but I just tested that this happens on Mikan main.)

This is an error: ``` data Bool : Set where true false : Bool foo : (Bool → Bool) → Bool → Bool foo f x with f x ``` This is only a warning: ``` data Bool : Set where true false : Bool foo : (Bool → Bool) → Bool → Bool foo f x with f x foo f x | true = false ``` Why? It very often happens to me that I start writing a complicated expression to pattern match on, so I write `with ...`, and I want to verify that this type-checks before starting to write the further clauses, so I instinctively press C-c C-l, and syntax highlighting suddenly disappears from my whole file. In those cases, I add a clause like `foo f x | _ = ?` just to make Agda stop complaining and let me use the hole system to interactively build up the scrutinee after `with`. (I've barely tried Mikan but I just tested that this happens on Mikan `main`.)

It would be fairly easy to move the MissingWithClauses exception into the NiceWarning enum since it's only thrown at unit type (i.e., it's a side-condition). The bigger question is how much of the elaborator needs to change to account for not having any with clauses. I'm less clear on that.

| MissingWithClauses Name LHS


when (null withClauses) $ declarationException $ MissingWithClauses x lhs
It would be fairly easy to move the `MissingWithClauses` exception into the `NiceWarning` enum since it's only thrown at unit type (i.e., it's a side-condition). The bigger question is how much of the elaborator needs to change to account for not having any `with` clauses. I'm less clear on that. https://codeberg.org/1lab/mikan/src/commit/5fd3212d213bcd23c6c00c13bf487f253d63b48d/src/full/Mikan/Syntax/Concrete/Definitions/Errors.hs#L48 https://codeberg.org/1lab/mikan/src/commit/5fd3212d213bcd23c6c00c13bf487f253d63b48d/src/full/Mikan/Syntax/Concrete/Definitions.hs#L840

There's also a BothWithAndRHS exception that we could turn into a warning, with no change to the elaborator, by just ignoring the extra RHS. The two RightHandSide [] (_:_) _ rhs _ cases need to be merged, and the warning would have to carry the (range of) the ignored RHS so it can be highlighted as dead code.

toAbstract (RightHandSide [] (_:_) _ (C.RHS _) _) = typeError BothWithAndRHS -- issue #7760
toAbstract (RightHandSide [] [] (_ , []) rhs NoWhere) = toAbstract rhs
toAbstract (RightHandSide [] (z:zs)(lv , c:cs) C.AbsurdRHS NoWhere) = do

The warning is for things like

foowithbar=baz...|_=quux
There's also a `BothWithAndRHS` exception that we could turn into a warning, with no change to the elaborator, by just ignoring the extra RHS. The two `RightHandSide [] (_:_) _ rhs _` cases need to be merged, and the warning would have to carry the (range of) the ignored RHS so it can be highlighted as dead code. https://codeberg.org/1lab/mikan/src/commit/5fd3212d213bcd23c6c00c13bf487f253d63b48d/src/full/Mikan/Syntax/Translation/ConcreteToAbstract.hs#L3445-L3447 The warning is for things like ```agda foo with bar = baz ... | _ = quux ```
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
No project
Assignees
Clear assignees
No assignees
2 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#124
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?