Skip to content

Diagnostic: a method named with the reserved word spawn is reported at the call site ("only available inside scope") instead of at the declaration #1303

Closed

Description

@ehartford

Found rewriting `examples/ecs` under #1150 ruling 4 (`World.spawn(name) -> Entity`, the ECS vocabulary).

```
type World { next_id: i32 = 0 }
extend World:
mut fn spawn(name: str) -> i32:
self.next_id += 1
self.next_id
mut fn spawn_player() -> i32:
self.spawn("player")
fn main:
var w = World {}
print(f"{w.spawn_player()}")
```

```
error: spawn() is only available inside scope
--> main.w:108:22
error: return type does not implement Default
```

The built-in `s.spawn(...)` for OS-thread scopes (§14.14) is matched by method name before the receiver's own methods are consulted, so no user type can have a `spawn` method. §18.2's precedence puts current-module declarations above builtins; the builtin should apply only when the receiver is a scope handle (the same class as #1153: builtins need explicit precedence). Installed `with v0.15.2.1-g478b26481`.

The example names the method `spawn_entity` until this lands.

Activity

  1. ehartford commented on Sep 22, 2026

    @ehartford
    ContributorAuthor

    Independent validation: not a builtin-precedence defect — spawn is a reserved word (§29.11 "spawn is reserved"; Token.w TK_KW_SPAWN): fn spawn(...) and let spawn are rejected at the declaration too. The example's spelling is wrong (spawn_entity is right; fixed in #1308). What remains is diagnostic quality: after extend/. the parser accepts fn spawn and Sema reports "only available inside scope" at the call site instead of "reserved keyword" at the declaration. Re-scoped to that.

  2. changed the title [-]A user method named `spawn` is intercepted by the built-in scope spawn(): "spawn() is only available inside scope"[/-] [+]Diagnostic: a method named with the reserved word `spawn` is reported at the call site ("only available inside scope") instead of at the declaration[/+] on Sep 22, 2026
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