Skip to content

Fill in dropped annotations and unaccounted attributes in the frontend - #157

Merged
simonspies merged 9 commits into
mainfrom
increase-testing
Aug 1, 2026
Merged

Fill in dropped annotations and unaccounted attributes in the frontend#157
simonspies merged 9 commits into
mainfrom
increase-testing

Conversation

@simonspies

Copy link
Copy Markdown
Owner

Closes the frontend gaps where an annotation or an attribute was silently dropped, and makes local recursion usable.

  • A type annotation written on a let pattern (let (x : T) = e) or on a match-arm payload is honored instead of discarded, so a wrong type is caught and a [@spec] written there is not lost.
  • An annotation on the name of a let that takes arguments is rejected rather than dropped, since the annotation there is the return type written after the arguments (and OCaml rejects the syntax outright).
  • A let with no arguments that is annotated both on its binder and after it is rejected, instead of the second annotation being silently dropped.
  • Every attribute on a value declaration is accounted for: an unknown name is rejected, and neither [@@spec] nor [@@fn] may be written twice.
  • An attribute carries its own source location, so an attribute error points at the attribute rather than at the declaration or at :0:0.
  • A local let rec binding a function literal is supported, which was the only way to give a local recursive function a specification and so the only way to write one at all.
  • A declaration's attributes are collected in a record rather than threaded as separate arguments and returned as a tuple.
  • Attribute names are a variant type rather than matched as strings.
  • Two gaps are pinned by tests rather than fixed: a type assignment (e : t) is still dropped (Support type assignments (e : t) #155) and () is still rejected in a binder position (Accept () in a binder position #156).

@simonspies
simonspies merged commit bc5d90d into main Aug 1, 2026
4 checks passed
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