Skip to content

🐛 Make clause guard field/tuple access recursive#138

Merged
the-mikedavis merged 3 commits intogleam-lang:mainfrom
fruno-bulax:main
Jan 5, 2026
Merged

🐛 Make clause guard field/tuple access recursive#138
the-mikedavis merged 3 commits intogleam-lang:mainfrom
fruno-bulax:main

Conversation

@fruno-bulax
Copy link
Contributor

Clause guards only allowed tuple/field access with a depth of one.

All of these could not be parsed correctly:

case wibble {
  _ if a.b.c -> True
  _ if a.0.1 -> True
  _ if a.b.0.a -> True
  _ if a.0.a.0 -> True
}

Note I'm way out of my depth with this one: Please pay special attention to the conflicts I added, I don't really know how to judge if they are okay! Feedback or direct edits are both welcome!

Comment on lines +316 to +319
(field_access
record: (identifier)
field: (label)
field: (label)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than multiple index/field fields, let's make this nested so instead it would be:

(field_access
  record:
    (field_access
      record: (identifier)
      field: (label))
  field: (label))

Especially when mixing records and tuples, having field on a tuple_access or index or a field_access doesn't make sense.

Copy link
Contributor Author

@fruno-bulax fruno-bulax Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right! I modeled this closely after how it's implemented in normal expressions, I'll have to check why it behaves differently

Copy link
Contributor Author

@fruno-bulax fruno-bulax Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was pulling my hair out over this, but it was just a missing alias 🤦
It was recursive, the recursive nodes were just dropped.

@the-mikedavis the-mikedavis linked an issue Dec 30, 2025 that may be closed by this pull request
Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@the-mikedavis the-mikedavis merged commit 3ed303b into gleam-lang:main Jan 5, 2026
3 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.

Grammar does not support nested field access in guards

2 participants