Summary
Naming has four channels and irverify reads three of them. Source, Canonical and Hint
are read by checkNaming (namingChannels, ir/irverify/naming.go:90) — Hint for the presence
test only, which is #54. Aliases is read by nothing anywhere in the pipeline: it appears in
production code exactly once, at its own declaration.
$ grep -rn "Aliases" --include='*.go' ir/ pass/ compilers/ engine/ | grep -v _test.go
ir/naming.go:28: // Aliases are alternate names for schema-resolution matching (Avro
ir/naming.go:31: Aliases []string `json:"aliases,omitempty"`
(The compilers/openapi/internal/scan hit is a comment about YAML aliases, unrelated.)
Reproduction
A model whose aliases are cased, punctuated, empty and duplicated verifies clean and validates
clean:
m := &ir.Model{TypeCommon: ir.TypeCommon{
ID: "t/x/M",
Name: ir.Naming{Source: "m", Canonical: "m",
Aliases: []string{"UserID", "com.example.User", "", "dup", "dup"}},
}}
// irverify.Verify → no violation
// pass.Validate → no diagnostic
Why it matters
An alias is an alternate name for schema-resolution matching (Avro aliases, Protobuf's
json_name alternates), so it is subject to the same invariant as the rest of the naming channel:
names are neutral, and an emitter owns casing and reserved-word escaping. An alias that arrives
already cased or already punctuated is a name the IR has decided the spelling of, which is exactly
what invariant 4 forbids and what ir/naming-cased and ir/naming-not-words exist to catch on
Canonical.
The empty and duplicated cases are cheaper claims and worth making at the same time: an empty
alias matches nothing and a repeated one matches twice, and both mean a compiler wrote a list it
did not mean to write.
Suggested shape
Extend checkNaming rather than adding a rule beside it — it already reaches every ir.Naming the
document holds through the shared walk, and namingChannels is where the fourth channel would be
read. The question worth settling first is which of the three existing content rules an alias is
held to. Canonical's grammar is the neutral lower_snake word sequence and an alias may
legitimately be a dotted fully-qualified name (com.example.User is what an Avro alias looks
like), so the answer is probably not "the same rules", and the issue should not be closed by
applying them unexamined.
Whatever set is chosen, ir/naming.go:28-31's doc comment should say it, since today it documents
what the field is for and nothing about what a well-formed entry looks like.
Summary
Naminghas four channels andirverifyreads three of them.Source,CanonicalandHintare read by
checkNaming(namingChannels,ir/irverify/naming.go:90) —Hintfor the presencetest only, which is #54.
Aliasesis read by nothing anywhere in the pipeline: it appears inproduction code exactly once, at its own declaration.
(The
compilers/openapi/internal/scanhit is a comment about YAML aliases, unrelated.)Reproduction
A model whose aliases are cased, punctuated, empty and duplicated verifies clean and validates
clean:
Why it matters
An alias is an alternate name for schema-resolution matching (Avro aliases, Protobuf's
json_namealternates), so it is subject to the same invariant as the rest of the naming channel:names are neutral, and an emitter owns casing and reserved-word escaping. An alias that arrives
already cased or already punctuated is a name the IR has decided the spelling of, which is exactly
what invariant 4 forbids and what
ir/naming-casedandir/naming-not-wordsexist to catch onCanonical.The empty and duplicated cases are cheaper claims and worth making at the same time: an empty
alias matches nothing and a repeated one matches twice, and both mean a compiler wrote a list it
did not mean to write.
Suggested shape
Extend
checkNamingrather than adding a rule beside it — it already reaches everyir.Namingthedocument holds through the shared walk, and
namingChannelsis where the fourth channel would beread. The question worth settling first is which of the three existing content rules an alias is
held to.
Canonical's grammar is the neutral lower_snake word sequence and an alias maylegitimately be a dotted fully-qualified name (
com.example.Useris what an Avro alias lookslike), so the answer is probably not "the same rules", and the issue should not be closed by
applying them unexamined.
Whatever set is chosen,
ir/naming.go:28-31's doc comment should say it, since today it documentswhat the field is for and nothing about what a well-formed entry looks like.