Skip to content

Commit 7ce86c9

Browse files
committed
Pulse: error on binder attributes, they are ignored
I was recently very confused by this, proposing to just error out until they are handled (if that becomes desirable). I plan to add attributes to the letbinding itself (instead of the individual pattern variables).
1 parent 306c261 commit 7ce86c9

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

pulse/src/syntax_extension/PulseSyntaxExtension.Desugar.fst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,13 @@ let rec desugar_stmt' (env:env_t) (s:Sugar.stmt)
509509

510510
| Sequence { s1={s=LetBinding lb; range=s1range}; s2 } ->
511511
begin match lb.pat.pat with
512-
| A.PatVar _
513-
| A.PatWild _ ->
514-
(* simple bind *)
512+
| A.PatVar (_, _, attrs)
513+
| A.PatWild (_, attrs) ->
514+
(* A simple bind. But error out if the user wrote binder
515+
attributes, since these are ignored. *)
516+
if Cons? attrs then
517+
fail "Binder attributes are not allowed." (pos (List.hd attrs))
518+
else return ();!
515519
desugar_bind env lb s2 s.range
516520
| _ ->
517521
(* a single-branch pattern match *)

pulse/test/NoBinderAttributes.fst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module NoBinderAttributes
2+
3+
#lang-pulse
4+
open Pulse
5+
6+
[@@expect_failure]
7+
fn test ()
8+
{
9+
let [@@@123] x = 1;
10+
();
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* Info at NoBinderAttributes.fst(9,10-9,13):
2+
- Expected failure:
3+
- Binder attributes are not allowed.
4+

0 commit comments

Comments
 (0)