| author | |
| committer | |
| log | 300c83d8930d15d4bc4e34fe11e3b6bf3130ecc4 |
| tree | 265aaeaaddef394074b425c0798bf656a8b09cb9 |
| parent | 5f28a9d23851d94edc2b24e549b7c5abbbf23f68 |
2 files changed, 15 insertions(+), 1 deletions(-)
src/analyze.cpp+1-1| ... | ... | @@ -2804,7 +2804,6 @@ static bool is_container(TypeTableEntry *type_entry) { |
| 2804 | 2804 | switch (type_entry->id) { |
| 2805 | 2805 | case TypeTableEntryIdInvalid: |
| 2806 | 2806 | case TypeTableEntryIdVar: |
| 2807 | case TypeTableEntryIdOpaque: | |
| 2808 | 2807 | zig_unreachable(); |
| 2809 | 2808 | case TypeTableEntryIdStruct: |
| 2810 | 2809 | case TypeTableEntryIdEnum: |
| ... | ... | @@ -2831,6 +2830,7 @@ static bool is_container(TypeTableEntry *type_entry) { |
| 2831 | 2830 | case TypeTableEntryIdBoundFn: |
| 2832 | 2831 | case TypeTableEntryIdEnumTag: |
| 2833 | 2832 | case TypeTableEntryIdArgTuple: |
| 2833 | case TypeTableEntryIdOpaque: | |
| 2834 | 2834 | return false; |
| 2835 | 2835 | } |
| 2836 | 2836 | zig_unreachable(); |
test/compile_errors.zig+14| ... | ... | @@ -2238,4 +2238,18 @@ pub fn addCases(cases: &tests.CompileErrorContext) { |
| 2238 | 2238 | \\} |
| 2239 | 2239 | , |
| 2240 | 2240 | ".tmp_source.zig:37:16: error: cannot store runtime value in compile time variable"); |
| 2241 | ||
| 2242 | cases.add("field access of opaque type", | |
| 2243 | \\const MyType = @OpaqueType(); | |
| 2244 | \\ | |
| 2245 | \\export fn entry() -> bool { | |
| 2246 | \\ var x: i32 = 1; | |
| 2247 | \\ return bar(@ptrCast(&MyType, &x)); | |
| 2248 | \\} | |
| 2249 | \\ | |
| 2250 | \\fn bar(x: &MyType) -> bool { | |
| 2251 | \\ return x.blah; | |
| 2252 | \\} | |
| 2253 | , | |
| 2254 | ".tmp_source.zig:9:13: error: type '&MyType' does not support field access"); | |
| 2241 | 2255 | } |