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