Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested attributes don’t cooperate well enough with repetition #534

Open
usaoc opened this issue Aug 7, 2024 · 0 comments
Open

Nested attributes don’t cooperate well enough with repetition #534

usaoc opened this issue Aug 7, 2024 · 0 comments

Comments

@usaoc
Copy link
Collaborator

usaoc commented Aug 7, 2024

This is an old known bug, but probably I should open an issue so that someone can take a look at it. Nested attributes are currently handled directly in pattern variables, which are transformers that look for a . followed by the symbolic attribute names. However, the implementation doesn’t cooperate well enough with repetition outside the syntax pattern. Namely, this program works

#lang rhombus
block:
  let [pattern
       | '9 $x $_'
       | '8 $x',
       ...]:
    ['8 1', '9 2 3']
  [x, ...]
  // ['1', '2']

while this doesn’t

#lang rhombus
block:
  let [pattern match
       | '9 $x $_'
       | '8 $x',
       ...]:
    ['8 1', '9 2 3']
  [match.x, ...]
  // x: no such field or method

Two relevant tests in rhombus/tests/syntax-class.rhm are commented out, and the comment suggests that :: has a similar bug. Indeed, this program works

#lang rhombus
block:
  syntax_class SomePattern
  | '9 $x $_'
  | '8 $x'
  let ['$(_ :: SomePattern: open)', ...]:
    ['8 1', '9 2 3']
  [x, ...]
  // ['1', '2']

while this doesn’t

#lang rhombus
block:
  syntax_class SomePattern
  | '9 $x $_'
  | '8 $x'
  let ['$(match :: SomePattern)', ...]:
    ['8 1', '9 2 3']
  [match.x, ...]
  // x: no such field or method
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

No branches or pull requests

1 participant