2020-05-18 15:45:06 +00:00
|
|
|
const builtin = @import("builtin");
|
|
|
|
|
2021-07-24 05:23:03 +00:00
|
|
|
test {
|
stage2: type system treats fn ptr and body separately
This commit updates stage2 to enforce the property that the syntax
`fn()void` is a function *body* not a *pointer*. To get a pointer, the
syntax `*const fn()void` is required.
ZIR puts function alignment into the func instruction rather than the
decl because this way it makes it into function types. LLVM backend
respects function alignments.
Struct and Union have methods `fieldSrcLoc` to help look up source
locations of their fields. These trigger full loading, tokenization, and
parsing of source files, so should only be called once it is confirmed
that an error message needs to be printed.
There are some nice new error hints for explaining why a type is
required to be comptime, particularly for structs that contain function
body types.
`Type.requiresComptime` is now moved into Sema because it can fail and
might need to trigger field type resolution. Comptime pointer loading
takes into account types that do not have a well-defined memory layout
and does not try to compute a byte offset for them.
`fn()void` syntax no longer secretly makes a pointer. You get a function
body type, which requires comptime. However a pointer to a function body
can be runtime known (obviously).
Compile errors that report "expected pointer, found ..." are factored
out into convenience functions `checkPtrOperand` and `checkPtrType` and
have a note about function pointers.
Implemented `Value.hash` for functions, enum literals, and undefined values.
stage1 is not updated to this (yet?), so some workarounds and disabled
tests are needed to keep everything working. Should we update stage1 to
these new type semantics? Yes probably because I don't want to add too
much conditional compilation logic in the std lib for the different
backends.
2022-01-21 07:49:58 +00:00
|
|
|
_ = @import("behavior/align.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/alignof.zig");
|
stage2: type system treats fn ptr and body separately
This commit updates stage2 to enforce the property that the syntax
`fn()void` is a function *body* not a *pointer*. To get a pointer, the
syntax `*const fn()void` is required.
ZIR puts function alignment into the func instruction rather than the
decl because this way it makes it into function types. LLVM backend
respects function alignments.
Struct and Union have methods `fieldSrcLoc` to help look up source
locations of their fields. These trigger full loading, tokenization, and
parsing of source files, so should only be called once it is confirmed
that an error message needs to be printed.
There are some nice new error hints for explaining why a type is
required to be comptime, particularly for structs that contain function
body types.
`Type.requiresComptime` is now moved into Sema because it can fail and
might need to trigger field type resolution. Comptime pointer loading
takes into account types that do not have a well-defined memory layout
and does not try to compute a byte offset for them.
`fn()void` syntax no longer secretly makes a pointer. You get a function
body type, which requires comptime. However a pointer to a function body
can be runtime known (obviously).
Compile errors that report "expected pointer, found ..." are factored
out into convenience functions `checkPtrOperand` and `checkPtrType` and
have a note about function pointers.
Implemented `Value.hash` for functions, enum literals, and undefined values.
stage1 is not updated to this (yet?), so some workarounds and disabled
tests are needed to keep everything working. Should we update stage1 to
these new type semantics? Yes probably because I don't want to add too
much conditional compilation logic in the std lib for the different
backends.
2022-01-21 07:49:58 +00:00
|
|
|
_ = @import("behavior/array.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
_ = @import("behavior/async_fn.zig");
|
2022-03-15 22:09:23 +00:00
|
|
|
_ = @import("behavior/atomics.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
_ = @import("behavior/await_struct.zig");
|
2022-02-08 21:35:34 +00:00
|
|
|
_ = @import("behavior/basic.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/bit_shifting.zig");
|
2022-02-22 12:52:40 +00:00
|
|
|
_ = @import("behavior/bitcast.zig");
|
2022-02-15 17:45:25 +00:00
|
|
|
_ = @import("behavior/bitreverse.zig");
|
stage2: type system treats fn ptr and body separately
This commit updates stage2 to enforce the property that the syntax
`fn()void` is a function *body* not a *pointer*. To get a pointer, the
syntax `*const fn()void` is required.
ZIR puts function alignment into the func instruction rather than the
decl because this way it makes it into function types. LLVM backend
respects function alignments.
Struct and Union have methods `fieldSrcLoc` to help look up source
locations of their fields. These trigger full loading, tokenization, and
parsing of source files, so should only be called once it is confirmed
that an error message needs to be printed.
There are some nice new error hints for explaining why a type is
required to be comptime, particularly for structs that contain function
body types.
`Type.requiresComptime` is now moved into Sema because it can fail and
might need to trigger field type resolution. Comptime pointer loading
takes into account types that do not have a well-defined memory layout
and does not try to compute a byte offset for them.
`fn()void` syntax no longer secretly makes a pointer. You get a function
body type, which requires comptime. However a pointer to a function body
can be runtime known (obviously).
Compile errors that report "expected pointer, found ..." are factored
out into convenience functions `checkPtrOperand` and `checkPtrType` and
have a note about function pointers.
Implemented `Value.hash` for functions, enum literals, and undefined values.
stage1 is not updated to this (yet?), so some workarounds and disabled
tests are needed to keep everything working. Should we update stage1 to
these new type semantics? Yes probably because I don't want to add too
much conditional compilation logic in the std lib for the different
backends.
2022-01-21 07:49:58 +00:00
|
|
|
_ = @import("behavior/bool.zig");
|
2023-07-24 17:54:08 +00:00
|
|
|
// Ideally, all tests would be categorized and independent from GitHub, but
|
|
|
|
// if that's too much trouble, having test coverage this way is better than nothing.
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/bugs/394.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/bugs/421.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
_ = @import("behavior/bugs/529.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/bugs/624.zig");
|
stage2: type system treats fn ptr and body separately
This commit updates stage2 to enforce the property that the syntax
`fn()void` is a function *body* not a *pointer*. To get a pointer, the
syntax `*const fn()void` is required.
ZIR puts function alignment into the func instruction rather than the
decl because this way it makes it into function types. LLVM backend
respects function alignments.
Struct and Union have methods `fieldSrcLoc` to help look up source
locations of their fields. These trigger full loading, tokenization, and
parsing of source files, so should only be called once it is confirmed
that an error message needs to be printed.
There are some nice new error hints for explaining why a type is
required to be comptime, particularly for structs that contain function
body types.
`Type.requiresComptime` is now moved into Sema because it can fail and
might need to trigger field type resolution. Comptime pointer loading
takes into account types that do not have a well-defined memory layout
and does not try to compute a byte offset for them.
`fn()void` syntax no longer secretly makes a pointer. You get a function
body type, which requires comptime. However a pointer to a function body
can be runtime known (obviously).
Compile errors that report "expected pointer, found ..." are factored
out into convenience functions `checkPtrOperand` and `checkPtrType` and
have a note about function pointers.
Implemented `Value.hash` for functions, enum literals, and undefined values.
stage1 is not updated to this (yet?), so some workarounds and disabled
tests are needed to keep everything working. Should we update stage1 to
these new type semantics? Yes probably because I don't want to add too
much conditional compilation logic in the std lib for the different
backends.
2022-01-21 07:49:58 +00:00
|
|
|
_ = @import("behavior/bugs/655.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/bugs/656.zig");
|
stage2: type system treats fn ptr and body separately
This commit updates stage2 to enforce the property that the syntax
`fn()void` is a function *body* not a *pointer*. To get a pointer, the
syntax `*const fn()void` is required.
ZIR puts function alignment into the func instruction rather than the
decl because this way it makes it into function types. LLVM backend
respects function alignments.
Struct and Union have methods `fieldSrcLoc` to help look up source
locations of their fields. These trigger full loading, tokenization, and
parsing of source files, so should only be called once it is confirmed
that an error message needs to be printed.
There are some nice new error hints for explaining why a type is
required to be comptime, particularly for structs that contain function
body types.
`Type.requiresComptime` is now moved into Sema because it can fail and
might need to trigger field type resolution. Comptime pointer loading
takes into account types that do not have a well-defined memory layout
and does not try to compute a byte offset for them.
`fn()void` syntax no longer secretly makes a pointer. You get a function
body type, which requires comptime. However a pointer to a function body
can be runtime known (obviously).
Compile errors that report "expected pointer, found ..." are factored
out into convenience functions `checkPtrOperand` and `checkPtrType` and
have a note about function pointers.
Implemented `Value.hash` for functions, enum literals, and undefined values.
stage1 is not updated to this (yet?), so some workarounds and disabled
tests are needed to keep everything working. Should we update stage1 to
these new type semantics? Yes probably because I don't want to add too
much conditional compilation logic in the std lib for the different
backends.
2022-01-21 07:49:58 +00:00
|
|
|
_ = @import("behavior/bugs/679.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/bugs/704.zig");
|
2022-03-04 08:06:25 +00:00
|
|
|
_ = @import("behavior/bugs/718.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/bugs/726.zig");
|
|
|
|
_ = @import("behavior/bugs/828.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
_ = @import("behavior/bugs/920.zig");
|
2022-02-03 21:25:46 +00:00
|
|
|
_ = @import("behavior/bugs/1025.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/bugs/1076.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/bugs/1277.zig");
|
|
|
|
_ = @import("behavior/bugs/1310.zig");
|
|
|
|
_ = @import("behavior/bugs/1381.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/bugs/1421.zig");
|
|
|
|
_ = @import("behavior/bugs/1442.zig");
|
2022-02-02 23:28:56 +00:00
|
|
|
_ = @import("behavior/bugs/1486.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/bugs/1500.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/bugs/1607.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/bugs/1735.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/bugs/1851.zig");
|
2022-02-03 21:25:46 +00:00
|
|
|
_ = @import("behavior/bugs/1914.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/bugs/2006.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/bugs/2114.zig");
|
2021-11-04 18:24:46 +00:00
|
|
|
_ = @import("behavior/bugs/2346.zig");
|
2022-10-17 12:19:16 +00:00
|
|
|
_ = @import("behavior/bugs/2557.zig");
|
2022-02-10 20:30:26 +00:00
|
|
|
_ = @import("behavior/bugs/2578.zig");
|
2022-12-07 20:37:40 +00:00
|
|
|
_ = @import("behavior/bugs/2622.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/bugs/2692.zig");
|
2022-12-07 20:37:40 +00:00
|
|
|
_ = @import("behavior/bugs/2727.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/bugs/2889.zig");
|
2022-02-10 20:30:26 +00:00
|
|
|
_ = @import("behavior/bugs/3007.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/bugs/3046.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/bugs/3112.zig");
|
|
|
|
_ = @import("behavior/bugs/3367.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/bugs/3384.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/bugs/3586.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/bugs/3742.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/bugs/3779.zig");
|
2022-02-26 16:06:06 +00:00
|
|
|
_ = @import("behavior/bugs/4328.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/bugs/4560.zig");
|
|
|
|
_ = @import("behavior/bugs/4769_a.zig");
|
|
|
|
_ = @import("behavior/bugs/4769_b.zig");
|
|
|
|
_ = @import("behavior/bugs/4954.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/bugs/5398.zig");
|
|
|
|
_ = @import("behavior/bugs/5413.zig");
|
|
|
|
_ = @import("behavior/bugs/5474.zig");
|
|
|
|
_ = @import("behavior/bugs/5487.zig");
|
2022-12-07 20:37:40 +00:00
|
|
|
_ = @import("behavior/bugs/6047.zig");
|
2022-03-15 22:09:23 +00:00
|
|
|
_ = @import("behavior/bugs/6456.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
_ = @import("behavior/bugs/6781.zig");
|
2022-01-05 22:51:26 +00:00
|
|
|
_ = @import("behavior/bugs/6850.zig");
|
2022-12-07 19:57:00 +00:00
|
|
|
_ = @import("behavior/bugs/6905.zig");
|
2022-12-07 20:37:40 +00:00
|
|
|
_ = @import("behavior/bugs/6947.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/bugs/7003.zig");
|
2022-03-10 18:00:07 +00:00
|
|
|
_ = @import("behavior/bugs/7047.zig");
|
2022-04-27 19:29:25 +00:00
|
|
|
_ = @import("behavior/bugs/7187.zig");
|
2022-12-07 19:08:28 +00:00
|
|
|
_ = @import("behavior/bugs/7325.zig");
|
2023-01-03 05:24:48 +00:00
|
|
|
_ = @import("behavior/bugs/8277.zig");
|
2022-12-07 19:57:00 +00:00
|
|
|
_ = @import("behavior/bugs/8646.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/bugs/9584.zig");
|
2022-04-27 19:29:25 +00:00
|
|
|
_ = @import("behavior/bugs/10138.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/bugs/10147.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/bugs/10970.zig");
|
2022-12-07 19:57:00 +00:00
|
|
|
_ = @import("behavior/bugs/10684.zig");
|
2022-03-12 02:31:29 +00:00
|
|
|
_ = @import("behavior/bugs/11046.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/bugs/11100.zig");
|
2022-03-14 17:37:23 +00:00
|
|
|
_ = @import("behavior/bugs/11139.zig");
|
2022-03-15 21:00:33 +00:00
|
|
|
_ = @import("behavior/bugs/11159.zig");
|
|
|
|
_ = @import("behavior/bugs/11162.zig");
|
2022-03-14 23:21:11 +00:00
|
|
|
_ = @import("behavior/bugs/11165.zig");
|
2022-05-26 12:50:50 +00:00
|
|
|
_ = @import("behavior/bugs/11179.zig");
|
2022-03-15 20:29:54 +00:00
|
|
|
_ = @import("behavior/bugs/11181.zig");
|
2022-03-18 15:22:42 +00:00
|
|
|
_ = @import("behavior/bugs/11213.zig");
|
2022-12-07 17:00:52 +00:00
|
|
|
_ = @import("behavior/bugs/11787.zig");
|
2022-09-15 08:33:56 +00:00
|
|
|
_ = @import("behavior/bugs/11816.zig");
|
2022-12-15 18:02:31 +00:00
|
|
|
_ = @import("behavior/bugs/11995.zig");
|
|
|
|
_ = @import("behavior/bugs/12000.zig");
|
2022-07-05 07:58:47 +00:00
|
|
|
_ = @import("behavior/bugs/12003.zig");
|
llvm: fix lowering of runtime refs to comptime-only decls
When we want a runtime pointer to a zero-bit value we use an undef
pointer, but what if we want a runtime pointer to a comptime-only value?
Normally, if `T` is a comptime-only type such as `*const comptime_int`,
then `*const T` would also be a comptime-only type, so anything
referencing a comptime-only value is usually also comptime-only, and
therefore not emitted to the executable.
However, what if instead we have a `*const anyopaque` pointing to a
comptime-only value? Certainly, `*const anyopaque` is a runtime type,
and so we need some runtime value to store, even when it happens to be
pointing to a comptime-only value. In this case we want to do the same
thing as we do when pointing to a zero-bit value, so we use
`hasRuntimeBits` to handle both cases instead of ignoring comptime.
Closes #12025
2022-10-15 06:02:21 +00:00
|
|
|
_ = @import("behavior/bugs/12025.zig");
|
2022-07-07 18:21:39 +00:00
|
|
|
_ = @import("behavior/bugs/12033.zig");
|
2022-10-05 12:34:49 +00:00
|
|
|
_ = @import("behavior/bugs/12043.zig");
|
2022-12-15 18:02:31 +00:00
|
|
|
_ = @import("behavior/bugs/12051.zig");
|
|
|
|
_ = @import("behavior/bugs/12092.zig");
|
|
|
|
_ = @import("behavior/bugs/12119.zig");
|
|
|
|
_ = @import("behavior/bugs/12142.zig");
|
|
|
|
_ = @import("behavior/bugs/12169.zig");
|
2022-08-12 21:47:54 +00:00
|
|
|
_ = @import("behavior/bugs/12430.zig");
|
2022-12-15 18:02:31 +00:00
|
|
|
_ = @import("behavior/bugs/12450.zig");
|
2022-08-26 08:37:17 +00:00
|
|
|
_ = @import("behavior/bugs/12486.zig");
|
2022-12-02 17:56:43 +00:00
|
|
|
_ = @import("behavior/bugs/12498.zig");
|
2022-09-15 08:33:56 +00:00
|
|
|
_ = @import("behavior/bugs/12551.zig");
|
2022-12-14 23:43:48 +00:00
|
|
|
_ = @import("behavior/bugs/12571.zig");
|
2022-09-25 13:14:15 +00:00
|
|
|
_ = @import("behavior/bugs/12644.zig");
|
2022-09-04 15:44:45 +00:00
|
|
|
_ = @import("behavior/bugs/12680.zig");
|
2022-12-07 02:06:48 +00:00
|
|
|
_ = @import("behavior/bugs/12723.zig");
|
|
|
|
_ = @import("behavior/bugs/12776.zig");
|
2022-09-09 12:23:36 +00:00
|
|
|
_ = @import("behavior/bugs/12786.zig");
|
2022-09-09 12:19:51 +00:00
|
|
|
_ = @import("behavior/bugs/12794.zig");
|
2022-09-09 21:53:26 +00:00
|
|
|
_ = @import("behavior/bugs/12801-1.zig");
|
|
|
|
_ = @import("behavior/bugs/12801-2.zig");
|
2022-09-23 14:36:37 +00:00
|
|
|
_ = @import("behavior/bugs/12885.zig");
|
2022-10-03 11:05:55 +00:00
|
|
|
_ = @import("behavior/bugs/12890.zig");
|
2022-09-19 07:39:56 +00:00
|
|
|
_ = @import("behavior/bugs/12891.zig");
|
2022-09-23 13:38:27 +00:00
|
|
|
_ = @import("behavior/bugs/12911.zig");
|
2022-09-23 09:00:02 +00:00
|
|
|
_ = @import("behavior/bugs/12928.zig");
|
2022-09-23 21:08:42 +00:00
|
|
|
_ = @import("behavior/bugs/12945.zig");
|
2022-10-04 00:14:24 +00:00
|
|
|
_ = @import("behavior/bugs/12972.zig");
|
2022-09-29 16:02:59 +00:00
|
|
|
_ = @import("behavior/bugs/12984.zig");
|
2022-11-10 18:58:34 +00:00
|
|
|
_ = @import("behavior/bugs/13064.zig");
|
|
|
|
_ = @import("behavior/bugs/13065.zig");
|
2022-10-12 09:40:59 +00:00
|
|
|
_ = @import("behavior/bugs/13068.zig");
|
2022-11-10 18:58:34 +00:00
|
|
|
_ = @import("behavior/bugs/13069.zig");
|
2022-10-17 10:39:40 +00:00
|
|
|
_ = @import("behavior/bugs/13112.zig");
|
2022-12-15 18:02:31 +00:00
|
|
|
_ = @import("behavior/bugs/13113.zig");
|
2022-10-11 06:57:48 +00:00
|
|
|
_ = @import("behavior/bugs/13128.zig");
|
2022-10-24 11:46:14 +00:00
|
|
|
_ = @import("behavior/bugs/13159.zig");
|
2022-10-18 16:11:54 +00:00
|
|
|
_ = @import("behavior/bugs/13171.zig");
|
2022-12-14 00:29:25 +00:00
|
|
|
_ = @import("behavior/bugs/13209.zig");
|
2022-10-24 14:30:47 +00:00
|
|
|
_ = @import("behavior/bugs/13285.zig");
|
2022-12-10 02:50:37 +00:00
|
|
|
_ = @import("behavior/bugs/13366.zig");
|
2022-11-03 23:56:23 +00:00
|
|
|
_ = @import("behavior/bugs/13435.zig");
|
2022-11-27 13:37:48 +00:00
|
|
|
_ = @import("behavior/bugs/13664.zig");
|
2022-11-30 13:22:34 +00:00
|
|
|
_ = @import("behavior/bugs/13714.zig");
|
2022-12-08 20:21:49 +00:00
|
|
|
_ = @import("behavior/bugs/13785.zig");
|
2023-03-12 17:08:15 +00:00
|
|
|
_ = @import("behavior/bugs/14854.zig");
|
2023-05-22 19:45:39 +00:00
|
|
|
_ = @import("behavior/bugs/15778.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
_ = @import("behavior/byteswap.zig");
|
|
|
|
_ = @import("behavior/byval_arg_var.zig");
|
2023-06-20 07:20:32 +00:00
|
|
|
_ = @import("behavior/c_char_signedness.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/call.zig");
|
2023-07-27 00:21:33 +00:00
|
|
|
_ = @import("behavior/call_tail.zig");
|
stage2: type system treats fn ptr and body separately
This commit updates stage2 to enforce the property that the syntax
`fn()void` is a function *body* not a *pointer*. To get a pointer, the
syntax `*const fn()void` is required.
ZIR puts function alignment into the func instruction rather than the
decl because this way it makes it into function types. LLVM backend
respects function alignments.
Struct and Union have methods `fieldSrcLoc` to help look up source
locations of their fields. These trigger full loading, tokenization, and
parsing of source files, so should only be called once it is confirmed
that an error message needs to be printed.
There are some nice new error hints for explaining why a type is
required to be comptime, particularly for structs that contain function
body types.
`Type.requiresComptime` is now moved into Sema because it can fail and
might need to trigger field type resolution. Comptime pointer loading
takes into account types that do not have a well-defined memory layout
and does not try to compute a byte offset for them.
`fn()void` syntax no longer secretly makes a pointer. You get a function
body type, which requires comptime. However a pointer to a function body
can be runtime known (obviously).
Compile errors that report "expected pointer, found ..." are factored
out into convenience functions `checkPtrOperand` and `checkPtrType` and
have a note about function pointers.
Implemented `Value.hash` for functions, enum literals, and undefined values.
stage1 is not updated to this (yet?), so some workarounds and disabled
tests are needed to keep everything working. Should we update stage1 to
these new type semantics? Yes probably because I don't want to add too
much conditional compilation logic in the std lib for the different
backends.
2022-01-21 07:49:58 +00:00
|
|
|
_ = @import("behavior/cast.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/cast_int.zig");
|
stage2: type system treats fn ptr and body separately
This commit updates stage2 to enforce the property that the syntax
`fn()void` is a function *body* not a *pointer*. To get a pointer, the
syntax `*const fn()void` is required.
ZIR puts function alignment into the func instruction rather than the
decl because this way it makes it into function types. LLVM backend
respects function alignments.
Struct and Union have methods `fieldSrcLoc` to help look up source
locations of their fields. These trigger full loading, tokenization, and
parsing of source files, so should only be called once it is confirmed
that an error message needs to be printed.
There are some nice new error hints for explaining why a type is
required to be comptime, particularly for structs that contain function
body types.
`Type.requiresComptime` is now moved into Sema because it can fail and
might need to trigger field type resolution. Comptime pointer loading
takes into account types that do not have a well-defined memory layout
and does not try to compute a byte offset for them.
`fn()void` syntax no longer secretly makes a pointer. You get a function
body type, which requires comptime. However a pointer to a function body
can be runtime known (obviously).
Compile errors that report "expected pointer, found ..." are factored
out into convenience functions `checkPtrOperand` and `checkPtrType` and
have a note about function pointers.
Implemented `Value.hash` for functions, enum literals, and undefined values.
stage1 is not updated to this (yet?), so some workarounds and disabled
tests are needed to keep everything working. Should we update stage1 to
these new type semantics? Yes probably because I don't want to add too
much conditional compilation logic in the std lib for the different
backends.
2022-01-21 07:49:58 +00:00
|
|
|
_ = @import("behavior/comptime_memory.zig");
|
2022-03-15 22:09:23 +00:00
|
|
|
_ = @import("behavior/const_slice_child.zig");
|
2022-12-07 02:06:48 +00:00
|
|
|
_ = @import("behavior/decltest.zig");
|
2023-05-08 07:59:06 +00:00
|
|
|
_ = @import("behavior/duplicated_test_names.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/defer.zig");
|
compiler: implement destructuring syntax
This change implements the following syntax into the compiler:
```zig
const x: u32, var y, foo.bar = .{ 1, 2, 3 };
```
A destructure expression may only appear within a block (i.e. not at
comtainer scope). The LHS consists of a sequence of comma-separated var
decls and/or lvalue expressions. The RHS is a normal expression.
A new result location type, `destructure`, is used, which contains
result pointers for each component of the destructure. This means that
when the RHS is a more complicated expression, peer type resolution is
not used: each result value is individually destructured and written to
the result pointers. RLS is always used for destructure expressions,
meaning every `const` on the LHS of such an expression creates a true
stack allocation.
Aside from anonymous array literals, Sema is capable of destructuring
the following types:
* Tuples
* Arrays
* Vectors
A destructure may be prefixed with the `comptime` keyword, in which case
the entire destructure is evaluated at comptime: this means all `var`s
in the LHS are `comptime var`s, every lvalue expression is evaluated at
comptime, and the RHS is evaluated at comptime. If every LHS is a
`const`, this is not allowed: as with single declarations, the user
should instead mark the RHS as `comptime`.
There are a few subtleties in the grammar changes here. For one thing,
if every LHS is an lvalue expression (rather than a var decl), a
destructure is considered an expression. This makes, for instance,
`if (cond) x, y = .{ 1, 2 };` valid Zig code. A destructure is allowed
in almost every context where a standard assignment expression is
permitted. The exception is `switch` prongs, which cannot be
destructures as the comma is ambiguous with the end of the prong.
A follow-up commit will begin utilizing this syntax in the Zig compiler.
Resolves: #498
2023-08-31 13:30:58 +00:00
|
|
|
_ = @import("behavior/destructure.zig");
|
2022-12-23 21:10:04 +00:00
|
|
|
_ = @import("behavior/empty_tuple_fields.zig");
|
2022-12-07 02:06:48 +00:00
|
|
|
_ = @import("behavior/empty_union.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/enum.zig");
|
|
|
|
_ = @import("behavior/error.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/eval.zig");
|
2023-06-15 17:30:00 +00:00
|
|
|
_ = @import("behavior/export_self_referential_type_info.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/field_parent_ptr.zig");
|
2022-03-03 00:28:39 +00:00
|
|
|
_ = @import("behavior/floatop.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
_ = @import("behavior/fn.zig");
|
2022-02-13 04:35:29 +00:00
|
|
|
_ = @import("behavior/fn_delegation.zig");
|
2022-01-05 22:51:26 +00:00
|
|
|
_ = @import("behavior/fn_in_struct_in_comptime.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/for.zig");
|
|
|
|
_ = @import("behavior/generics.zig");
|
2022-01-05 22:51:26 +00:00
|
|
|
_ = @import("behavior/hasdecl.zig");
|
2022-01-06 22:23:29 +00:00
|
|
|
_ = @import("behavior/hasfield.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/if.zig");
|
|
|
|
_ = @import("behavior/import.zig");
|
|
|
|
_ = @import("behavior/incomplete_struct_param_tld.zig");
|
2022-12-07 02:06:48 +00:00
|
|
|
_ = @import("behavior/inline_switch.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/int128.zig");
|
2022-11-14 23:56:59 +00:00
|
|
|
_ = @import("behavior/int_comparison_elision.zig");
|
2023-06-15 07:14:16 +00:00
|
|
|
_ = @import("behavior/ptrfromint.zig");
|
2022-02-13 04:35:29 +00:00
|
|
|
_ = @import("behavior/ir_block_deps.zig");
|
2022-12-13 21:55:59 +00:00
|
|
|
_ = @import("behavior/lower_strlit_to_vector.zig");
|
2022-03-03 08:23:50 +00:00
|
|
|
_ = @import("behavior/math.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/maximum_minimum.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/member_func.zig");
|
2023-04-27 21:01:16 +00:00
|
|
|
_ = @import("behavior/memcpy.zig");
|
2023-04-26 19:49:32 +00:00
|
|
|
_ = @import("behavior/memset.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/merge_error_sets.zig");
|
2022-03-02 06:46:57 +00:00
|
|
|
_ = @import("behavior/muladd.zig");
|
2022-01-23 19:19:14 +00:00
|
|
|
_ = @import("behavior/namespace_depends_on_compile_var.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/null.zig");
|
2022-02-10 01:19:03 +00:00
|
|
|
_ = @import("behavior/optional.zig");
|
2022-12-07 02:06:48 +00:00
|
|
|
_ = @import("behavior/packed-struct.zig");
|
|
|
|
_ = @import("behavior/packed_struct_explicit_backing_int.zig");
|
2023-07-29 09:51:33 +00:00
|
|
|
_ = @import("behavior/packed-union.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/pointers.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/popcount.zig");
|
2022-03-02 06:46:57 +00:00
|
|
|
_ = @import("behavior/prefetch.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/ptrcast.zig");
|
2022-03-02 06:46:57 +00:00
|
|
|
_ = @import("behavior/pub_enum.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig");
|
2022-03-02 06:46:57 +00:00
|
|
|
_ = @import("behavior/reflection.zig");
|
2023-03-17 02:40:47 +00:00
|
|
|
_ = @import("behavior/return_address.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/saturating_arithmetic.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
_ = @import("behavior/select.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/shuffle.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/sizeof_and_typeof.zig");
|
|
|
|
_ = @import("behavior/slice.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/slice_sentinel_comptime.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/src.zig");
|
2022-03-02 06:46:57 +00:00
|
|
|
_ = @import("behavior/struct.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/struct_contains_null_ptr_itself.zig");
|
2022-03-22 07:23:54 +00:00
|
|
|
_ = @import("behavior/struct_contains_slice_of_itself.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/switch.zig");
|
2022-03-09 17:26:48 +00:00
|
|
|
_ = @import("behavior/switch_prong_err_enum.zig");
|
|
|
|
_ = @import("behavior/switch_prong_implicit_cast.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/this.zig");
|
2022-12-07 04:48:48 +00:00
|
|
|
_ = @import("behavior/threadlocal.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/translate_c_macros.zig");
|
2022-02-13 04:35:29 +00:00
|
|
|
_ = @import("behavior/truncate.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/try.zig");
|
2022-02-13 04:35:29 +00:00
|
|
|
_ = @import("behavior/tuple.zig");
|
2022-12-07 02:06:48 +00:00
|
|
|
_ = @import("behavior/tuple_declarations.zig");
|
2022-02-13 04:35:29 +00:00
|
|
|
_ = @import("behavior/type.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/type_info.zig");
|
2023-07-25 15:15:59 +00:00
|
|
|
_ = @import("behavior/type_info_only_pub_decls.zig");
|
2022-03-18 07:12:22 +00:00
|
|
|
_ = @import("behavior/typename.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/undefined.zig");
|
|
|
|
_ = @import("behavior/underscore.zig");
|
|
|
|
_ = @import("behavior/union.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/union_with_members.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/usingnamespace.zig");
|
2022-02-13 04:35:29 +00:00
|
|
|
_ = @import("behavior/var_args.zig");
|
2022-03-17 06:54:25 +00:00
|
|
|
_ = @import("behavior/vector.zig");
|
2022-02-22 13:15:09 +00:00
|
|
|
_ = @import("behavior/void.zig");
|
|
|
|
_ = @import("behavior/while.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/widening.zig");
|
2023-07-17 23:52:14 +00:00
|
|
|
_ = @import("behavior/abs.zig");
|
2021-04-29 21:51:21 +00:00
|
|
|
|
2022-07-25 02:05:20 +00:00
|
|
|
if (builtin.cpu.arch == .wasm32) {
|
2022-03-03 18:16:30 +00:00
|
|
|
_ = @import("behavior/wasm.zig");
|
|
|
|
}
|
|
|
|
|
2022-03-23 21:06:07 +00:00
|
|
|
if (builtin.os.tag != .wasi) {
|
2022-03-20 21:04:28 +00:00
|
|
|
_ = @import("behavior/asm.zig");
|
2022-03-23 21:06:07 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 13:15:09 +00:00
|
|
|
if (builtin.zig_backend != .stage2_arm and
|
|
|
|
builtin.zig_backend != .stage2_x86_64 and
|
|
|
|
builtin.zig_backend != .stage2_aarch64 and
|
2023-05-11 05:53:34 +00:00
|
|
|
builtin.zig_backend != .stage2_c and
|
|
|
|
builtin.zig_backend != .stage2_spirv64)
|
2022-02-22 13:15:09 +00:00
|
|
|
{
|
2022-11-01 16:22:31 +00:00
|
|
|
_ = @import("behavior/bugs/13063.zig");
|
2022-03-21 11:25:57 +00:00
|
|
|
_ = @import("behavior/bugs/11227.zig");
|
2023-01-04 20:18:17 +00:00
|
|
|
_ = @import("behavior/bugs/14198.zig");
|
2022-03-18 22:02:52 +00:00
|
|
|
_ = @import("behavior/export.zig");
|
2022-07-05 22:46:12 +00:00
|
|
|
}
|
2019-01-30 02:47:26 +00:00
|
|
|
}
|