Skip to content

Improve syntax for record updates and access #816

Description

@shonfeder

I think we should remove the field operator, because, as @lasarojc found out, its type signature is a lie:

>>> val r = {a: 2}

>>> val f = "a"

>>> r.field(f)
static analysis error: error: [QNT000] Record field name must be a string expression but is name: f
Generating record constraints for r,f
Generating constraints for f

r.field(f)
^^^^^^^^^^


2

either f doesn't have type string, or the type signature for field is incorrect.

For the same reason, we should replace with with an update syntax that doesn't pretend to take strings :)

E.g., {r with a : 42}.

We could introduce the ability to pass around labels, perhaps indexed by union types, around. But this would be significantly more involved.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions