Skip to content

when handlers don't watch bare-name RHS operands (reactive dependency gap) #28

@rmichaelthomas

Description

@rmichaelthomas

Severity: medium (reactive correctness — handler can fail to re-fire)

A bare name on the right-hand side of a when/unless condition is not added to the handler's watched set, so the handler does not re-evaluate when that variable changes. A field-access RHS (<field> of <record>) is watched.

Reproducer

remember a number called reading with 0
remember a number called limit with 50
when reading is above limit
  show "over"
  finish
Listening for changes to: reading          # `limit` is NOT watched

Contrast with a field-access RHS:

when reading is above limit of cfg
Listening for changes to: reading, cfg     # the record IS watched

Root cause

_parse_value produces a BareWord for a bare RHS name (the "might be a name, might be a string" ambiguity). interpreter._walk_dependencies treats BareWord (like all literals) as contributing no dependency, so the name never enters the watched set. Only NameRef and FieldAccessNode operands are walked.

Consequence

If another handler (or cascade) changes limit, a when reading is above limit handler will not re-evaluate against the new threshold — it only reacts to changes in reading. The condition silently uses a stale threshold.

Notes

  • General to all comparison operators (above/below/equal_to/within/…), not specific to any one. Surfaced while implementing within is counted as a base reserved word but has no base-language behavior #19 (within), where within N of <name> showed the same: only the field was watched.
  • Possible fixes: (a) in a when/condition context, resolve a bare RHS name that exists in the symbol table to a NameRef (so it's watched), or (b) have _walk_dependencies also treat a BareWord whose word is a known symbol as a dependency. Either needs care around the bare-word-as-string-literal case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglanguage-designChanges to Liminate language design or specification

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions