Skip to content

Laurel: field access on Any-typed values#1421

Open
julesmt wants to merge 2 commits into
reviewed-kbd-will-merge-to-mainfrom
laurel/any-composite-bridge
Open

Laurel: field access on Any-typed values#1421
julesmt wants to merge 2 commits into
reviewed-kbd-will-merge-to-mainfrom
laurel/any-composite-bridge

Conversation

@julesmt

@julesmt julesmt commented Jun 26, 2026

Copy link
Copy Markdown
Member

Adds the read-side bridge that lets Laurel resolve and read a field on a value
whose static type is Any (a class instance carried by reference), by unboxing
it to its heap Composite. Gated on the program defining an Any datatype, so
existing Laurel programs are unaffected.

Example:
Python values often reach Laurel typed Any (unannotated parameters, spec
self, heterogeneous containers). Reading an attribute then has to recover the
underlying object:

class Account:
    balance: int

def is_rich(a):                # `a` is unannotated → `Any` in Laurel
    return a.balance > 1000    # attribute read on an `Any`-typed value

Jules added 2 commits June 26, 2026 10:38
Bridge functions plus a readField hook and TypeHierarchy injection,
active only when a program defines an `Any` datatype. Inert otherwise.
resolveFieldRef does a cross-scope field lookup only for `Any`-typed
targets, so a concrete target can't bind an unrelated composite's field.
Adds regression tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant