Skip to content

Commit

Permalink
Avoid linting for $$ with &convert
Browse files Browse the repository at this point in the history
Attributes on a field with `&convert` make `$$` mean something
different. $$ refers to before the conversion, `self.field` revers to
after.
  • Loading branch information
evantypanski committed Oct 30, 2024
1 parent 6329a65 commit fd763af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions rule-tests/use-dd-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ valid:
- "type X = unit { x: uint8 { $$; } };"
- "type X = unit { x: uint8 { other.y; } };"
- "type X = unit { y: uint8 { self.x; } };"
- "type X = unit { x: uint8 &convert=$$ + 5 { self.x; $$; } };"
invalid:
- "type X = unit { x: uint8 { self.x; } };"
- "type X = unit { x: uint8 { if (True) self.x; } };"
7 changes: 7 additions & 0 deletions rules/use-dd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ rule:
field: "name"
kind: "ident"
pattern: "$F"
not:
inside:
kind: "field_decl"
stopBy: "end"
has:
kind: "attribute"
regex: "&convert"

fix: "$$"

Expand Down

0 comments on commit fd763af

Please # to comment.