Stream: bugs

Topic: Record field name with dollar prefix


view this post on Zulip Jonathan (Jul 03 2026 at 15:05):

Just tested this in the latest repl. I was surprised to find that you could create a record with a field name prefixed by a dollar:
my_record = {$field : 1}
But of course if you try to access that, it's a syntax error
my_record.$field

┌─────────────┐
│ PARSE ERROR ├─ A parsing error occurred: statement_unexpected_token ────────┐
└┬────────────┘                                                               │
 │                                                                            │
 │  main = my_record.$field                                                   │
 │                   ‾‾                                                       │
 └───────────────────────────────────────────────────────────────── repl:3:18 ┘

    This is an unexpected parsing error. Please check your syntax.

view this post on Zulip Jonathan (Jul 03 2026 at 15:11):

You can access the value if you pattern match into a variable of the same name, however

… var $a = 0
… {$a} = {$a : 1}
… $a
# Returns 1.0

but I'm not sure if this is intentional. I would have thought that you can destructure into {$a} but from a record of type { a : value}

view this post on Zulip Richard Feldman (Jul 03 2026 at 15:58):

yeah that's not intentional - $ should be disallowed in record field names! :smile:

view this post on Zulip Richard Feldman (Jul 03 2026 at 15:59):

@Jonathan would you mind opening a GitHub issue for this with type=Bug ?

view this post on Zulip Jonathan (Jul 03 2026 at 16:06):

No prob #9936. Don't believe I have permissions to add a label though.

view this post on Zulip Anton (Jul 03 2026 at 16:22):

I added the label


Last updated: Jul 23 2026 at 13:15 UTC