Skip to content

feat(lint): reject len() in when patterns (E0508) - #27

Merged
srnnkls merged 1 commit into
mainfrom
feat/lint-reject-len-in-when
Jun 30, 2026
Merged

feat(lint): reject len() in when patterns (E0508)#27
srnnkls merged 1 commit into
mainfrom
feat/lint-reject-len-in-when

Conversation

@srnnkls

@srnnkls srnnkls commented Jun 30, 2026

Copy link
Copy Markdown
Owner

len() inside when computes over the pattern's materialised value
(e.g. [] for open lists), not the input's, so the result is always a
fixed constant. Reject at load time with E0508 and guide users toward
list.MatchN instead.

  • Add E0508 diagnostic code with help text
  • Reject len CallExpr in lintWhen walker
  • Remove len from permittedUniverseBuiltins
  • Remove now-unreachable evaluator test for len-inert-under-subsumption
  • Add unit test, fixture rule, and scrut integration test
  • Update AGENTS.md

Extracted from the @Bind lattice PR; standalone on main.

`len()` inside `when` computes over the pattern's materialised value
(e.g. `[]` for open lists), not the input's, so the result is always a
fixed constant. Reject at load time with E0508 and guide users toward
`list.MatchN` instead.

- Add E0508 diagnostic code with help text
- Reject `len` CallExpr in lintWhen walker
- Remove `len` from permittedUniverseBuiltins
- Remove now-unreachable evaluator test for len-inert-under-subsumption
- Add unit test, fixture rule, and scrut integration test
- Update AGENTS.md
@srnnkls
srnnkls merged commit 9c4936d into main Jun 30, 2026
5 checks passed
@srnnkls
srnnkls deleted the feat/lint-reject-len-in-when branch June 30, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant