-
In the spec, many type validation rules require uniqueness of various elements when applying an extension. For example, this, from 3.8.1 Union Extensions:
and this, from 3.6.3 Object Extensions:
Is this intended to also disallow multiple extension clauses adding the same element, or is the intent only that extensions must not duplicate the "original" declaration? Again, I hope examples will help clarify.... This is clearly a violation, because the "original" declaration and the extension both specify member
Is this also a violation? Both extension clauses specify member
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It may be poorly worded, but I think essentially the "original type" is replaced by the extension. So in this example: union MyUnion = Foo
extend union MyUnion = Bar | Baz
extend union MyUnion = Bar | Qux After line one, I think the usage of the word "original" here may be problematic, really we're just referencing the "current type with this name before the extension is applied" rather than "the first instance of this type being defined ever". What happens if you feed this example into the reference implementation? |
Beta Was this translation helpful? Give feedback.
It may be poorly worded, but I think essentially the "original type" is replaced by the extension. So in this example:
After line one,
MyUnion
is newly created, withunion MyUnion = Foo
After line two,
MyUnion
has been replaced such that nowunion MyUnion = Foo | Bar | Baz
Line three would be invalid since the "original"
MyUnion
type we're extending is the type defined on line 2, and already containsBar
.I think the usage of the word "original" here may be problematic, really we're just referencing the "current type with this name before the extension is applied" rather than "the first instance of this …