Skip to content

Ten declaration words are keywords only where their construct can begin; spawn is not reserved (closes #3132) - #3628

Merged
ehartford merged 7 commits into
mainfrom
contextual-keywords
Nov 26, 2026
Merged

ehartford merged 7 commits into
mainfrom
contextual-keywords

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #3132, as Eric ruled on 2026-11-25 (D235): the ten words become contextual, spawn is dropped, type stays reserved. The words in §29.11 are delegated (D98, D236); spec v7.92.

What changes for a program. c_import dyn ephemeral extend gen global module opaque union where and spawn are ordinary names wherever their construct cannot begin: a binding, a field, a parameter, a method (List.extend can now be declared). A C field or function with one of those names keeps its C name (ev.module, not ev.module_).

How. One pass after tokenizing (lexer_contextual_words): each word keeps its keyword token only in its position, so the parser is unchanged. The positions: gen before fn or a function modifier; where and dyn before a name; extend before a name, or type parameters and a name; global before a name or var; module at the start of a line before a name; opaque, union, ephemeral in a type/enum declaration after the name, its ] or its =; c_import between use and (. The lexer has the contextual words in their own table, and :spec-inventory-check compares it with the spec's list.

A diagnostic fixed on the way. Two names side by side in a body (foo work()) were reported as "file has both fn main and top-level executable statements". They are now reported where they are, which is what a mistyped declaration word now produces.

Tests. behav_3132_declaration_words_are_names (all eleven as names beside their keyword uses), err_two_names_side_by_side; four existing tests that pinned the old refusal or the underscored C names follow the ruling.

Not in this PR. Importing a C field named type under its own name (Eric's note on the issue): filed separately below.

Evidence. Battery GREEN on 00a147c; :release-checks green on the same commit (the corpus lanes tokenize with the new pass).

@ehartford
ehartford enabled auto-merge (squash) November 26, 2026 08:50
@ehartford
ehartford merged commit aeac980 into main Nov 26, 2026
1 check passed
@ehartford
ehartford deleted the contextual-keywords branch November 26, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant