Commit 83f9754e authored by Kenton Varda's avatar Kenton Varda

Require a colon before 'group' or 'union' except for unnamed unions as well as…

Require a colon before 'group' or 'union' except for unnamed unions as well as the legacy case of a named union with an ordinal (where the colon is optional).
parent 89ee9afe
......@@ -37,14 +37,14 @@ enum Operation {
struct Expression {
op@0: Operation;
left @1 union {
value@2: Int32;
expression@3: Expression;
left :union {
value@1: Int32;
expression@2: Expression;
}
right @4 union {
value@5: Int32;
expression@6: Expression;
right :union {
value@3: Int32;
expression@4: Expression;
}
}
......
......@@ -223,9 +223,9 @@ struct Declaration {
name @0 :LocatedText; # If null, param failed to parse.
type @1 :TypeExpression;
annotations @2 :List(AnnotationApplication);
defaultValue @3 union {
none @4 :Void;
value @5 :ValueExpression;
defaultValue :union {
none @3 :Void;
value @4 :ValueExpression;
}
}
}
......
......@@ -1437,7 +1437,7 @@ static const ::capnp::_::AlignedData<74> b_fffe08a9a697d2a5 = {
96, 0, 0, 0, 2, 0, 1, 0,
116, 0, 0, 0, 2, 0, 1, 0,
3, 0, 0, 0, 0, 0, 0, 0,
1, 0, 1, 0, 3, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0,
71, 234, 136, 253, 21, 69, 16, 229,
113, 0, 0, 0, 106, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
......@@ -1505,14 +1505,14 @@ static const ::capnp::_::AlignedData<48> b_e5104515fd88ea47 = {
108, 117, 101, 0, 0, 0, 0, 0,
8, 0, 0, 0, 3, 0, 4, 0,
0, 0, 255, 255, 0, 0, 0, 0,
0, 0, 1, 0, 4, 0, 0, 0,
0, 0, 1, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 42, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
36, 0, 0, 0, 2, 0, 1, 0,
44, 0, 0, 0, 2, 0, 1, 0,
1, 0, 254, 255, 3, 0, 0, 0,
0, 0, 1, 0, 5, 0, 0, 0,
0, 0, 1, 0, 4, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 50, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
......
......@@ -205,14 +205,14 @@ TEST(Lexer, Statements) {
"tokens = ["
"(identifier = 'foo', endByte = 3)"
"], "
"block = (statements = ["
"block = ["
"(tokens = ["
"(identifier = 'bar', startByte = 5, endByte = 8)"
"], startByte = 5, endByte = 9), "
"(tokens = ["
"(identifier = 'baz', startByte = 10, endByte = 13)"
"], startByte = 10, endByte = 14)"
"]), "
"], "
"endByte = 15"
"), "
"(tokens = ["
......@@ -300,14 +300,14 @@ TEST(Lexer, DocComments) {
"tokens = ["
"(identifier = 'foo', endByte = 3)"
"], "
"block = (statements = ["
"block = ["
"(tokens = ["
"(identifier = 'bar', startByte = 17, endByte = 20)"
"], docComment = 'hi\\n', startByte = 17, endByte = 27), "
"(tokens = ["
"(identifier = 'baz', startByte = 28, endByte = 31)"
"], startByte = 28, endByte = 32)"
"]), "
"], "
"docComment = 'blah blah\\n', "
"endByte = 44"
"), "
......@@ -323,14 +323,14 @@ TEST(Lexer, DocComments) {
"tokens = ["
"(identifier = 'foo', endByte = 3)"
"], "
"block = (statements = ["
"block = ["
"(tokens = ["
"(identifier = 'bar', startByte = 5, endByte = 8)"
"], startByte = 5, endByte = 9), "
"(tokens = ["
"(identifier = 'baz', startByte = 10, endByte = 13)"
"], startByte = 10, endByte = 14)"
"]), "
"], "
"docComment = 'late comment\\n', "
"endByte = 31"
"), "
......
......@@ -224,7 +224,7 @@ Lexer::Lexer(Orphanage orphanageParam, const ErrorReporter& errorReporterParam)
KJ_IF_MAYBE(c, comment) {
attachDocComment(builder, kj::mv(*c));
}
builder.getBlock().setNone();
builder.setLine();
return result;
}),
transform(
......@@ -241,7 +241,7 @@ Lexer::Lexer(Orphanage orphanageParam, const ErrorReporter& errorReporterParam)
} else KJ_IF_MAYBE(c, lateComment) {
attachDocComment(builder, kj::mv(*c));
}
auto list = builder.getBlock().initStatements(statements.size());
auto list = builder.initBlock(statements.size());
for (uint i = 0; i < statements.size(); i++) {
list.adoptWithCaveats(i, kj::mv(statements[i]));
}
......
......@@ -44,15 +44,15 @@ struct Token {
struct Statement {
tokens @0 :List(Token);
block @1 union {
none @2 :Void;
statements @3 :List(Statement);
union {
line @1 :Void;
block @2 :List(Statement);
}
docComment @4 :Text;
docComment @3 :Text;
startByte @5 :UInt32;
endByte @6 :UInt32;
startByte @4 :UInt32;
endByte @5 :UInt32;
}
struct LexedTokens {
......
......@@ -181,17 +181,17 @@ const ::capnp::_::RawSchema s_91cc55cd57de5419 = {
0x91cc55cd57de5419, b_91cc55cd57de5419.words, 165, d_91cc55cd57de5419, m_91cc55cd57de5419,
1, 9, i_91cc55cd57de5419, nullptr, nullptr
};
static const ::capnp::_::AlignedData<87> b_c6725e678d60fa37 = {
static const ::capnp::_::AlignedData<110> b_c6725e678d60fa37 = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
55, 250, 96, 141, 103, 94, 114, 198,
0, 0, 0, 0, 1, 0, 2, 0,
238, 195, 31, 98, 210, 86, 57, 167,
3, 0, 7, 0, 0, 0, 0, 0,
3, 0, 7, 0, 0, 0, 2, 0,
0, 0, 0, 0, 0, 0, 0, 0,
17, 0, 0, 0, 42, 1, 0, 0,
33, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
29, 0, 0, 0, 31, 1, 0, 0,
29, 0, 0, 0, 87, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
99, 97, 112, 110, 112, 47, 99, 111,
109, 112, 105, 108, 101, 114, 47, 108,
......@@ -199,42 +199,49 @@ static const ::capnp::_::AlignedData<87> b_c6725e678d60fa37 = {
110, 112, 58, 83, 116, 97, 116, 101,
109, 101, 110, 116, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 1, 0,
20, 0, 0, 0, 3, 0, 4, 0,
24, 0, 0, 0, 3, 0, 4, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
125, 0, 0, 0, 58, 0, 0, 0,
153, 0, 0, 0, 58, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
120, 0, 0, 0, 2, 0, 1, 0,
140, 0, 0, 0, 2, 0, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0,
1, 0, 1, 0, 1, 0, 0, 0,
100, 202, 149, 252, 126, 130, 2, 221,
137, 0, 0, 0, 50, 0, 0, 0,
148, 0, 0, 0, 2, 0, 1, 0,
168, 0, 0, 0, 2, 0, 1, 0,
1, 0, 255, 255, 0, 0, 0, 0,
0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
165, 0, 0, 0, 42, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
160, 0, 0, 0, 2, 0, 1, 0,
168, 0, 0, 0, 2, 0, 1, 0,
2, 0, 254, 255, 1, 0, 0, 0,
0, 0, 1, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
2, 0, 0, 0, 2, 0, 0, 0,
0, 0, 1, 0, 4, 0, 0, 0,
165, 0, 0, 0, 50, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
113, 0, 0, 0, 90, 0, 0, 0,
160, 0, 0, 0, 2, 0, 1, 0,
180, 0, 0, 0, 2, 0, 1, 0,
3, 0, 0, 0, 2, 0, 0, 0,
0, 0, 1, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
112, 0, 0, 0, 2, 0, 1, 0,
120, 0, 0, 0, 2, 0, 1, 0,
3, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 0, 5, 0, 0, 0,
177, 0, 0, 0, 90, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
117, 0, 0, 0, 82, 0, 0, 0,
176, 0, 0, 0, 2, 0, 1, 0,
184, 0, 0, 0, 2, 0, 1, 0,
4, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 0, 4, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
116, 0, 0, 0, 2, 0, 1, 0,
124, 0, 0, 0, 2, 0, 1, 0,
4, 0, 0, 0, 2, 0, 0, 0,
0, 0, 1, 0, 6, 0, 0, 0,
181, 0, 0, 0, 82, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
180, 0, 0, 0, 2, 0, 1, 0,
188, 0, 0, 0, 2, 0, 1, 0,
5, 0, 0, 0, 2, 0, 0, 0,
0, 0, 1, 0, 5, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
121, 0, 0, 0, 66, 0, 0, 0,
185, 0, 0, 0, 66, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
116, 0, 0, 0, 2, 0, 1, 0,
124, 0, 0, 0, 2, 0, 1, 0,
180, 0, 0, 0, 2, 0, 1, 0,
188, 0, 0, 0, 2, 0, 1, 0,
116, 111, 107, 101, 110, 115, 0, 0,
14, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
......@@ -245,7 +252,23 @@ static const ::capnp::_::AlignedData<87> b_c6725e678d60fa37 = {
14, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
108, 105, 110, 101, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
98, 108, 111, 99, 107, 0, 0, 0,
14, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 0, 1, 0,
16, 0, 0, 0, 0, 0, 0, 0,
55, 250, 96, 141, 103, 94, 114, 198,
0, 0, 0, 0, 0, 0, 0, 0,
14, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
100, 111, 99, 67, 111, 109, 109, 101,
110, 116, 0, 0, 0, 0, 0, 0,
12, 0, 0, 0, 0, 0, 0, 0,
......@@ -272,74 +295,13 @@ static const ::capnp::_::AlignedData<87> b_c6725e678d60fa37 = {
};
static const ::capnp::_::RawSchema* const d_c6725e678d60fa37[] = {
&s_91cc55cd57de5419,
&s_dd02827efc95ca64,
};
static const uint16_t m_c6725e678d60fa37[] = {1, 2, 4, 3, 0};
static const uint16_t i_c6725e678d60fa37[] = {0, 1, 2, 3, 4};
const ::capnp::_::RawSchema s_c6725e678d60fa37 = {
0xc6725e678d60fa37, b_c6725e678d60fa37.words, 87, d_c6725e678d60fa37, m_c6725e678d60fa37,
2, 5, i_c6725e678d60fa37, nullptr, nullptr
};
static const ::capnp::_::AlignedData<50> b_dd02827efc95ca64 = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
100, 202, 149, 252, 126, 130, 2, 221,
37, 0, 0, 0, 1, 0, 2, 0,
55, 250, 96, 141, 103, 94, 114, 198,
3, 0, 7, 0, 1, 0, 2, 0,
0, 0, 0, 0, 0, 0, 0, 0,
17, 0, 0, 0, 90, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
29, 0, 0, 0, 119, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
99, 97, 112, 110, 112, 47, 99, 111,
109, 112, 105, 108, 101, 114, 47, 108,
101, 120, 101, 114, 46, 99, 97, 112,
110, 112, 58, 83, 116, 97, 116, 101,
109, 101, 110, 116, 46, 98, 108, 111,
99, 107, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 3, 0, 4, 0,
0, 0, 255, 255, 0, 0, 0, 0,
0, 0, 1, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 42, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
36, 0, 0, 0, 2, 0, 1, 0,
44, 0, 0, 0, 2, 0, 1, 0,
1, 0, 254, 255, 1, 0, 0, 0,
0, 0, 1, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 90, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
40, 0, 0, 0, 2, 0, 1, 0,
60, 0, 0, 0, 2, 0, 1, 0,
110, 111, 110, 101, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
115, 116, 97, 116, 101, 109, 101, 110,
116, 115, 0, 0, 0, 0, 0, 0,
14, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 0, 1, 0,
16, 0, 0, 0, 0, 0, 0, 0,
55, 250, 96, 141, 103, 94, 114, 198,
0, 0, 0, 0, 0, 0, 0, 0,
14, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, }
};
static const ::capnp::_::RawSchema* const d_dd02827efc95ca64[] = {
&s_c6725e678d60fa37,
};
static const uint16_t m_dd02827efc95ca64[] = {0, 1};
static const uint16_t i_dd02827efc95ca64[] = {0, 1};
const ::capnp::_::RawSchema s_dd02827efc95ca64 = {
0xdd02827efc95ca64, b_dd02827efc95ca64.words, 50, d_dd02827efc95ca64, m_dd02827efc95ca64,
1, 2, i_dd02827efc95ca64, nullptr, nullptr
static const uint16_t m_c6725e678d60fa37[] = {2, 3, 5, 1, 4, 0};
static const uint16_t i_c6725e678d60fa37[] = {1, 2, 0, 3, 4, 5};
const ::capnp::_::RawSchema s_c6725e678d60fa37 = {
0xc6725e678d60fa37, b_c6725e678d60fa37.words, 110, d_c6725e678d60fa37, m_c6725e678d60fa37,
2, 6, i_c6725e678d60fa37, nullptr, nullptr
};
static const ::capnp::_::AlignedData<35> b_9e69a92512b19d18 = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
......@@ -441,8 +403,6 @@ CAPNP_DEFINE_STRUCT(
::capnp::compiler::Token);
CAPNP_DEFINE_STRUCT(
::capnp::compiler::Statement);
CAPNP_DEFINE_STRUCT(
::capnp::compiler::Statement::Block);
CAPNP_DEFINE_STRUCT(
::capnp::compiler::LexedTokens);
CAPNP_DEFINE_STRUCT(
......
This diff is collapsed.
......@@ -706,32 +706,55 @@ CapnpParser::CapnpParser(Orphanage orphanageParam, const ErrorReporter& errorRep
return DeclParserResult(kj::mv(decl));
}));
// Parse an ordinal followed by an optional colon, or no ordinal but require a colon.
auto& ordinalOrColon = arena.copy(p::oneOf(
p::transform(p::sequence(parsers.ordinal, p::optional(op("!")), p::optional(op(":"))),
[this](Orphan<LocatedInteger>&& ordinal,
kj::Maybe<kj::Tuple<>> exclamation,
kj::Maybe<kj::Tuple<>> colon)
-> kj::Maybe<Orphan<LocatedInteger>> {
if (exclamation == nullptr) {
errorReporter.addErrorOn(ordinal.getReader(),
"As of Cap'n Proto v0.3, it is no longer necessary to assign numbers to "
"unions. However, removing the number will break binary compatibility. "
"If this is an old protocol and you need to retain compatibility, please "
"add an exclamation point after the number to indicate that it is really "
"needed, e.g. `foo @1! :union {`. If this is a new protocol or compatibility "
"doesn't matter, just remove the @n entirely. Sorry for the inconvenience, "
"and thanks for being an early adopter! :)");
}
if (colon == nullptr) {
errorReporter.addErrorOn(ordinal.getReader(),
"As of Cap'n Proto v0.3, the 'union' keyword should be prefixed with a colon "
"for named unions, e.g. `foo :union {`.");
}
return kj::mv(ordinal);
}),
p::transform(op(":"),
[]() -> kj::Maybe<Orphan<LocatedInteger>>{ return nullptr; })));
parsers.unionDecl = arena.copy(p::transform(
// Hacky: The first branch of this oneOf() can correctly match named unions as well as
// anonymous unions that have an ordinal, but fails to match anonymous unions wil no
// ordinal because the "union" keyword is matched as an identifier and interpreted as
// the name, and then parsing fails after that. So, we have the second branch which
// just matches the "union" keyword alone, and injects dummy null values for the
// name and ordinal.
// The first branch of this oneOf() matches named unions. The second branch matches unnamed
// unions and generates dummy values for the parse results.
p::oneOf(
p::sequence(
p::optional(identifier), p::optional(parsers.ordinal),
p::optional(op(":")), keyword("union"), p::many(parsers.annotation)),
p::sequence(
keyword("union"),
p::optional([](ParserInput&) -> kj::Maybe<Located<Text::Reader>> { return nullptr; }),
p::optional([](ParserInput&) -> kj::Maybe<Orphan<LocatedInteger>>{ return nullptr; }),
p::optional([](ParserInput&) -> kj::Maybe<kj::Tuple<>> { return nullptr; }),
p::many(parsers.annotation))),
[this](kj::Maybe<Located<Text::Reader>>&& name,
identifier, ordinalOrColon,
keyword("union"), p::many(parsers.annotation)),
p::transform(keyword("union"),
[]() {
return kj::tuple(
Located<Text::Reader>("", 0, 0),
kj::Maybe<Orphan<LocatedInteger>>(nullptr),
kj::Array<Orphan<Declaration::AnnotationApplication>>(nullptr));
})),
[this](Located<Text::Reader>&& name,
kj::Maybe<Orphan<LocatedInteger>>&& ordinal,
kj::Maybe<kj::Tuple<>>&&,
kj::Array<Orphan<Declaration::AnnotationApplication>>&& annotations)
-> DeclParserResult {
auto decl = orphanage.newOrphan<Declaration>();
auto builder = decl.get();
KJ_IF_MAYBE(n, name) {
n->copyTo(builder.initName());
if (name.value.size() > 0) {
name.copyTo(builder.initName());
}
KJ_IF_MAYBE(ord, ordinal) {
builder.getId().adoptOrdinal(kj::mv(*ord));
......@@ -747,9 +770,8 @@ CapnpParser::CapnpParser(Orphanage orphanageParam, const ErrorReporter& errorRep
}));
parsers.groupDecl = arena.copy(p::transform(
p::sequence(identifier, p::optional(op(":")), keyword("group"), p::many(parsers.annotation)),
p::sequence(identifier, op(":"), keyword("group"), p::many(parsers.annotation)),
[this](Located<Text::Reader>&& name,
kj::Maybe<kj::Tuple<>>&&,
kj::Array<Orphan<Declaration::AnnotationApplication>>&& annotations)
-> DeclParserResult {
auto decl = orphanage.newOrphan<Declaration>();
......@@ -943,17 +965,17 @@ kj::Maybe<Orphan<Declaration>> CapnpParser::parseStatement(
builder.setStartByte(statement.getStartByte());
builder.setEndByte(statement.getEndByte());
switch (statement.getBlock().which()) {
case Statement::Block::NONE:
switch (statement.which()) {
case Statement::LINE:
if (output->memberParser != nullptr) {
errorReporter.addError(statement.getStartByte(), statement.getEndByte(),
"This statement should end with a semicolon, not a block.");
}
break;
case Statement::Block::STATEMENTS:
case Statement::BLOCK:
KJ_IF_MAYBE(memberParser, output->memberParser) {
auto memberStatements = statement.getBlock().getStatements();
auto memberStatements = statement.getBlock();
kj::Vector<Orphan<Declaration>> members(memberStatements.size());
for (auto memberStatement: memberStatements) {
KJ_IF_MAYBE(member, parseStatement(memberStatement, *memberParser)) {
......
......@@ -408,6 +408,14 @@ TEST(Stringify, UnnamedUnions) {
" bar = 123,\n"
" after = \"foooooooooooooooooooooooooooooooo\" )",
prettyPrint(root).flatten());
root.setFoo(0);
EXPECT_EQ("(before = \"before\", after = \"foooooooooooooooooooooooooooooooo\")", kj::str(root));
EXPECT_EQ(
"( before = \"before\",\n"
" after = \"foooooooooooooooooooooooooooooooo\" )",
prettyPrint(root).flatten());
}
TEST(Stringify, StructUnions) {
......
......@@ -207,6 +207,8 @@ static kj::StringTree print(const DynamicValue::Reader& value,
unionValue = kj::strTree(
fieldProto.getName(), " = ",
print(structValue.get(*field), whichFieldType(*field), indent.next(), PREFIXED));
} else {
which = nullptr;
}
}
......
......@@ -177,7 +177,7 @@ struct TestOutOfOrder {
}
struct TestUnion {
union0 @0 union {
union0 @0! :union {
# Pack union 0 under ideal conditions: there is no unused padding space prior to it.
u0f0s0 @4: Void;
u0f0s1 @5: Bool;
......@@ -200,7 +200,7 @@ struct TestUnion {
# Pack one bit in order to make pathological situation for union1.
bit0 @18: Bool;
union1 @1 union {
union1 @1! :union {
# Pack pathologically bad case. Each field takes up new space.
u1f0s0 @19: Void;
u1f0s1 @20: Bool;
......@@ -237,7 +237,7 @@ struct TestUnion {
# Interleave two unions to be really annoying.
# Also declare in reverse order to make sure union discriminant values are sorted by field number
# and not by declaration order.
union2 @2 union {
union2 @2! :union {
u2f0s64 @54: Int64;
u2f0s32 @52: Int32;
u2f0s16 @50: Int16;
......@@ -245,7 +245,7 @@ struct TestUnion {
u2f0s1 @45: Bool;
}
union3 @3 union {
union3 @3! :union {
u3f0s64 @55: Int64;
u3f0s32 @53: Int32;
u3f0s16 @51: Int16;
......@@ -422,13 +422,13 @@ struct TestLateUnion {
bar @1 :Text;
baz @2 :Int16;
theUnion @3 union {
theUnion @3! :union {
qux @4 :Text;
corge @5 :List(Int32);
grault @6 :Float32;
}
anotherUnion @7 union {
anotherUnion @7! :union {
qux @8 :Text;
corge @9 :List(Int32);
grault @10 :Float32;
......@@ -452,7 +452,7 @@ struct TestNewVersion {
}
struct TestStructUnion {
un @0 union {
un @0! :union {
allTypes @1 :TestAllTypes;
object @2 :TestObject;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment