fix(format): treat a selector-folded label as naming its macro

The lexer folds NAME.selector into one identifier, and an object macro
reached through the selector expands with it travelling along, so a
label spelled NAME.selector: restructures exactly like the bare name
would.  The macro-name checks now resolve the prefix before the first
period, and the crashing input joins the corpus.

Assisted-by: GLM 5.3
This commit is contained in:
petrbalvin committed 2026-10-07 13:54:42 +02:00
1 parent f932c5811c
commit 373ec51061
3 files changed
+33 -5

No files matched your search

+11
View File
@@ -127,6 +127,17 @@ func TestFormatPreservesExpansionSemantics(t *testing.T) {
"\tA: M:\n" +
"\tRET\n",
},
{
// A label reached through a selector: the lexer folds NAME and
// .selector into one identifier, and the object macro behind the
// name expands with the selector travelling along, so the folded
// spelling restructures exactly like the bare name.
name: "label naming a macro through a selector",
src: "#define A B\n" +
"TEXT ·f(SB), $0\n" +
"\tA.: A0\n" +
"\tRET\n",
},
{
// A use above its define: the name is not a macro at that point
// of the file, so splitting would be safe; the whole-file set