1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
# Licensed under the MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# This file is intended to test that various error cases are detected as errors. The error
# output is matched against a golden file. The file name has the .nobuild extension to make
# sure that a build system which automatically builds .capnp files does not try to build this one.
#
@0xccd0890aa4926a9b;
# Can't really test the missing-ID error because the output is intentionally unpredictable.
const notType :Int32 = 123;
annotation notFieldAnnotation(struct) :Int32;
annotation fieldAnnotation(field) :Int32;
struct Foo {
dupName @0 :Int32;
dupName @1 :Int32;
dupNumber1 @2 :Int32;
dupNumber2 @2 :Int32;
missingNumber @4 :Int32;
next @5 :Int32;
emptyUnion :union {}
emptyGroup :group {}
singletonUnion :union {
field @6 :Int32;
}
union {
dupName @7 :Int32;
f8 @8 :Int32;
}
union {
f9 @9 :Int32;
f10 @10 :Int32;
}
struct wrongTypeStyle {}
WrongFieldStyle @11 :Int32;
under_score @12 :Int32;
containsStruct :group {
f13 @13 :Int32;
struct CantNestHere {}
}
retroUnion @16! :union {
f14 @14 :Int32;
f15 @15 :Int32;
}
missingColonAndEclamation @18 union {
f19 @19 :Int32;
f20 @20 :Int32;
}
missingExclamation @21 :union {
f22 @22 :Int32;
f23 @23 :Int32;
}
missingColon @24! union {
f19 @25 :Int32;
f20 @26 :Int32;
}
unnamedInNamed :union {
f27 @27 :Int32;
f28 @28 :Int32;
union {
# content is ignored
}
}
listWithoutParam @31 :List;
listWithTooManyParams @32 :List(Int32, Int64);
listAnyPointer @33 :List(AnyPointer);
notAType @34 :notType;
noParams @35 :Foo(Int32);
defaultOutOfRange @36 :Int16 = 1234567;
defaultOutOfRange2 @37 :UInt16 = -1;
defaultWrongType @38 :Text = 123;
defaultWrongType2 @39 :Text = [123];
defaultWrongType3 @40 :Text = (foo = 123, bar = 456);
defaultTooBigToBeNegative @41 :Int64 = -0x8000000000000001;
defaultNotConstant @42 :Int32 = .Foo;
defaultConstantNotQualified @43 :Int32 = notType;
notAnnotation @44 :Int32 $Foo(123);
badAnnotation @45 :Int32 $notFieldAnnotation(123);
notVoidAnnotation @46 :Int32 $fieldAnnotation;
undefinedImport @17 :import "noshuchfile.capnp".Bar;
undefinedAbsolute @47 : .NoSuch;
undefinedRelative @29 :NoSuch;
undefinedMember @30 :Foo.NoSuch;
}
struct Bar {
x @3 :Text;
someGroup :group {
defaultMissingFieldName @2 :Bar = (x = "abcd", 456);
defaultNoSuchField @0 :Bar = (nosuchfield = 123);
defaultGroupMismatch @1 :Bar = (someGroup = 123);
}
}
using Bar;
enum DupEnumerants {
dupName @0;
dupName @1;
dupNumber1 @2;
dupNumber2 @2;
}
const recursive: UInt32 = .recursive;
struct Generic(T, U) {
}
struct UseGeneric {
tooFew @0 :Generic(Text);
tooMany @1 :Generic(Text, Data, List(Int32));
doubleBind @2 :Generic(Text, Data)(Data, Text);
primitiveBinding @3 :Generic(Text, Int32);
}
const embedBadType :UInt32 = embed "binary";
const embedNoSuchFile :Data = embed "no-such-file";