Check for distinct declarations in parsing
- Dominant language
- Standard ML
- Stars
- 44
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Issue https://github.com/CakeML/pure/issues/27 ensures that most dead code still gets type-checked. However there are still [problems](https://github.com/CakeML/pure/issues/27#issuecomment-1466223902) with multiple declarations of the same name due to the [`letrec` distinctness pass](https://github.com/CakeML/pure/blob/65f55650c57cd04e5cd36f0aed2c9e59faf00252/compiler/backend/passes/pure_letrec_cexpScript.sml#L105). Also, the parser must still check for closed expressions, even though type inference already does this.
As discussed in a meeting, this issue suggests:
- moving distinct declaration checking to parsing: remove the existing pass and reject programs with multiple declarations of the same name
- removing the parser closedness check, relying on [this result](https://github.com/CakeML/pure/blob/65f55650c57cd04e5cd36f0aed2c9e59faf00252/compiler/backend/passes/proofs/pure_letrecProofScript.sml#L1540) to lift type inference checks upwards
Unfortunately it is not enough to check top-level declarations only, as demand analysis proofs require [`letrec_distinct`](https://github.com/CakeML/pure/blob/8993d77f45afa042f0b5e730b94c1fe7bf2d9876/compiler/backend/passes/proofs/pure_letrecProofScript.sml#L68-L81).
Rejection of programs with multiple declarations of the same name is in line with GHC. However, if we support function-clause pattern-matching in the future, we must be careful to align with GHC's behaviour in warning on overlapping patterns rather than rejecting programs when appropriate.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.