Skip to content

fix(analyser): allow safe dynamic RHS in augmented assignment #211

Description

@timfennis

Reproduction

let ranges = [(0, [(1, 2)])];
let values = [];
values ++= ranges.pop()[1];

The analyser reports:

mismatched types: found Any but expected List<Any>

Expected behavior

The compiler should defer this call to runtime. The left side has type List, and the runtime overload for ++= can confirm that the right side is a list before mutating it.

Cause

The stdlib declares pop(List) -> Any, so indexing the returned tuple also produces Any. augmented_rhs_is_compatible requires the inferred right type to subtype the left type before it accepts a specialized mutation. It rejects Any without considering the runtime parameter type of the dynamic overload candidate.

The check should accept an unknown right side when each eligible runtime candidate preserves the left type. It must keep rejecting cases such as appending an unknown List to List.

Workaround

values ++= list(ranges.pop()[1]);

Found while running Advent of Code 2025 day 9 part 2 on master.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions