fix(format): never peel a stacked label that names a macro

Peeling a stacked label whose name is a macro moves it onto a line of
its own, where its expansion decides the line's shape: an empty body
leaves a bare colon behind, a line the parser rejects.  The peel loops
now hold such labels back with the rest of the line, 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 b54d2b4520
commit f932c5811c
3 files changed
+18 -3

No files matched your search

+10
View File
@@ -117,6 +117,16 @@ func TestFormatPreservesExpansionSemantics(t *testing.T) {
"\tA: M\n" +
"\tRET\n",
},
{
// A stacked label naming a macro: its expansion decides what
// the line becomes (an empty body makes it vanish), so it is
// never peeled onto a line of its own.
name: "stacked label naming a macro",
src: "#define M\n" +
"TEXT ·f(SB), $0\n" +
"\tA: M:\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