Skip to content

[dsl] Actor-associated modifiers cannot be applied — the actor prefix stays in the declared name #100

Closed

Description

@JArmandoAnaya

Symptom

A modifier declared in the §7.2.2.2.9 prefixed form is unreachable from any
application site:

actor thing
modifier thing.tweak:
    v: int

scenario thing.demo:
    t: thing
    t.tweak(1)     # error: unknown modifier 'tweak' (§7.3.12.4)

Unassociated modifiers (modifier tweak:) apply correctly, so the defect is
specific to the actor-associated form.

Cause

Parser::parse_structured keeps the whole qualified behavior name, so the
declaration modifier thing.tweak creates a type whose simple_name is
thing.tweak (parser.cpp, the qualified-behavior-name loop). The declare
pass records the prefix separately in TypeInfo::actor but leaves the name
alone (resolve.cpp, Declaration::Kind::Structured).

Resolver::check_modifier_application then looks the modifier up by
application.name alone — tweak — which no scope contains
(resolve.cpp:1056).

Correct behavior (§7.3.12.4.1)

The application syntax is [<actor-expression>.]<modifier-name>(...). Lookup
should resolve the actor expression's type and find the modifier associated with
that type or one of its supertypes. §7.3.12.4.1 also allows the actor to be
omitted "when it is the same as the scenario actor the modifier is applied in",
so an unprefixed application inside scenario thing.demo must find
thing.tweak too.

Applying a modifier whose associated actor is unrelated to the receiver should
be an error citing §7.3.12.4.

Impact

Every actor-associated modifier the bundled standard library declares is
currently un-appliable — stationary_object.location and vehicle.tow_trailer
(§8.7, PR #97), and the twelve map search-space modifiers of §8.12.2.2
(§8.12.2, this milestone). §8.9's movement modifiers (p8-s3, #46) are the same
shape, so that sprint depends on this.

The library itself checks clean — the declarations are well-formed and the
defect is purely on the application side.

Scope

frontends/dsl/src/resolve.cpp (check_modifier_application), plus cases in
frontends/dsl/tests/dsl_types_test.cpp for: application through an actor
expression, application with the actor omitted inside the associated scenario,
rejection when the receiver's type is unrelated, and inheritance through a
supertype. A pinning case in dsl_stdlib_test.cpp should apply one of the
map modifiers once it works.

Refs #43

Activity

  1. JArmandoAnaya commented on Aug 2, 2026

    @JArmandoAnaya
    ContributorAuthor

    Second facet, found while translating §8.9: with:-block applications are not checked at all

    The original report covers a modifier application as a scenario member. The
    other position §7.3.12.4.1 defines — inside a with: block on a behavior
    invocation — is not validated at all:

    scenario s:
        v1: vehicle
        do serial:
            v1.drive() with:
                no_such_modifier(1)      # accepted silently: Status::Ok, 0 diagnostics
    

    Resolver::check_modifier_application is reached for Member::Kind::ModifierApplication
    (resolve.cpp:1123) but not for the applications collected in a with block
    (resolve.cpp:1447 walks member.with.modifiers for expressions only). Since
    the with: block is where the domain model expects nearly every movement
    modifier to be applied, this is the larger half of the gap.

    Both facets should be fixed together, since both need the same thing: resolve
    the application's name against the receiver's type (or, with the actor omitted,
    against the enclosing scenario's actor) per §7.3.12.4.1.

    What §7.3.12.2 says about scoping

    Worth recording, because it also settles where an associated modifier's name
    lives:

    <modifier-name> — A unique name, either in the actor scope (if an actor
    is specified) or the global scope (if an associated actor is not specified).

    Today an actor-associated modifier is interned in the namespace's type table
    under its dotted name (std::vehicle.keep_lane). That happens to avoid
    collisions, but it is not the scoping the language describes, and it is why
    lookup by simple name fails.

    Extra test material from §8.9

    The §8.9 translation (43g) gives this fix a ready-made surface: fourteen
    actor-associated movement modifiers on movable_object and vehicle, plus
    three unassociated ones. Once application works, dsl_stdlib_test.cpp should
    gain a case that applies one of each from a with: block, and one that rejects
    a modifier whose associated actor is unrelated to the receiver.

  2. JArmandoAnaya commented on Aug 2, 2026

    @JArmandoAnaya
    ContributorAuthor

    Reopening: this was closed on 2026-08-02 without a fix. The defect is still live on main at 203f44e — an actor-associated modifier is unreachable from both of §7.3.12.4.1's application positions, and a with:-block application is not validated at all. p8-s3 (#46) depends on it, so it is the next task after #43 closes.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions