aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
AgeCommit message (Collapse)Author
2022-09-13stage2: remove pointless discards from source codeAndrew Kelley
Good riddance!
2022-09-12Sema: introduce Type.ptrAlignmentAdvancedAndrew Kelley
I'm not sure why the other commits in this branch caused this fix to be necessary. Also, there seems to be more fixes necessary before tests will pass.
2022-09-12stage2: change how defers are stored in ZirVeikka Tuominen
Storing defers this way has the benefits that the defer doesn't get analyzed multiple times in AstGen, it takes up less space, and it makes Sema aware of defers allowing for 'unreachable else prong' error on error sets in generic code. The disadvantage is that it is a bit more complex and errdefers with payloads now emit a placeholder instruction (but those are rare). Sema.zig before: Total ZIR bytes: 3.7794370651245117MiB Instructions: 238996 (2.051319122314453MiB) String Table Bytes: 89.2802734375KiB Extra Data Items: 430144 (1.640869140625MiB) Sema.zig after: Total ZIR bytes: 3.3344192504882812MiB Instructions: 211829 (1.8181428909301758MiB) String Table Bytes: 89.2802734375KiB Extra Data Items: 374611 (1.4290275573730469MiB)
2022-09-08Sema: fix UAF in zirClosureGetVeikka Tuominen
Previously if a decl failed its capture scope would be deallocated and set to undefined which would then lead to invalid dereference in `zirClosureGet`. To avoid this set the capture scope to a special failed state and fail the current decl with dependency failure if the failed state is encountered in `zirClosureGet`. Closes #12433 Closes #12530 Closes #12593
2022-09-08Sema: preserve alignment of const decl pointersVeikka Tuominen
Closes #12769
2022-09-08Sema: correct types in `@memset` and `@memcpy`Veikka Tuominen
Closes #12750
2022-09-03Merge pull request #12723 from Vexu/stage2-fixesVeikka Tuominen
Stage2 fixes
2022-09-03Sema: only ABI sized packed structs are extern compatibleVeikka Tuominen
2022-09-02Sema: remove unused src param from typeRequiresComptimeVeikka Tuominen
2022-09-02Sema: improve behavior of comptime_int backed enumsVeikka Tuominen
2022-09-02Sema: add error for enum tag value overflowVeikka Tuominen
Closes #12291
2022-09-02Sema: fix noalias coercion error messageVeikka Tuominen
Closes #11769
2022-09-02Sema: do not emit dbg_inline_end after NoReturnVeikka Tuominen
Closes #12698
2022-09-02Sema: resolve lazy value before intToFloatVeikka Tuominen
Closes #12698
2022-09-02stage2: fix panic when the dependency is missingriChar
2022-09-01Sema: add more validation to coerceVarArgParamVeikka Tuominen
Closes #12706
2022-08-30Sema: prevent access of undefined fieldsAndrew Kelley
When instantiating a generic function, there is a period of time where the function is inserted into monomorphed_funcs map, but is not yet initialized. Despite semantic analysis being single-threaded, generic function instantiation can happen recursively, meaning that the hash and equality functions for monomorphed_funcs entries are potentially invoked for an uninitialized function. This problem was mitigated by pre-setting the hash field on the newly allocated function, however it did not solve the problem for hash collisions in which case the equality function would be invoked. That it was solved for hash() but not eql() explains why the problem was difficult to observe. I tested this patch by temporarily sabotaging the hash and making it always return 0. This fix is centered on adding a new field to Module.Fn which is the one checked by eql() and is populated pre-initialization. closes #12643
2022-08-30avoid exposing supportsTailCall in the standard libraryAndrew Kelley
This is problematic because in practice it depends on whether the compiler backend supports it too, as evidenced by the TODO comment about LLVM not supporting some architectures that in fact do support tail calls. Instead this logic is organized strategically in src/target.zig, part of the internal compiler source code, and the behavior tests in question duplicate some logic for deciding whether to proceed with the test. The proper place to expose this flag is in `@import("builtin")` - the generated source file - so that third party compilers can advertise whether they support tail calls.
2022-08-30Sema: check that target supports tail callsVeikka Tuominen
2022-08-30stage2 llvm: use tag value instead of field index in airUnionInitVeikka Tuominen
Closes #12656
2022-08-30Sema: shift of comptime int with runtime valueVeikka Tuominen
Closes #12290
2022-08-30Sema: do not emit generic poison for non generic parametersVeikka Tuominen
Closes #12679
2022-08-30Sema: improve handling of always_tail call modifierVeikka Tuominen
Closes #4301 Closes #5692 Closes #6281 Closes #10786 Closes #11149 Closes #11776
2022-08-30coff: reorganize the linkerJakub Konka
2022-08-29Sema: fix access of inactive union field when enum and union fields are in ↵Veikka Tuominen
different order Closes #12667
2022-08-28Sema: add missing calls to resolveStructLayoutVeikka Tuominen
Closes #12645
2022-08-28Sema: correct one possible value for tuplesVeikka Tuominen
Closes #12376
2022-08-28Sema: fix handling of non-standard int types in empty non-exhaustive enumsVeikka Tuominen
Closes #12649
2022-08-28Sema: add error for switch on sliceVeikka Tuominen
Closes #12651
2022-08-27Sema: add error for non-comptime param in comptime funcantlilja
Adds error for taking a non comptime parameter in a function returning a comptime-only type but not when that type is dependent on a parameter. Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-26Sema: ensure resolveTypeFields is called for optional and error union typesmartinhath
We call `sema.resolveTypeFields` in order to get the fields of structs and unions inserted into their data structures. If it isn't called, it can happen that the fields of a type is queried before those fields are inserted into (for instance) `Module.Union.fields`, which would result in a wrong 'no field named' error. Fixes: #12486
2022-08-25Sema: ignore comptime params in partial func type checkVeikka Tuominen
This fixes a bug exposed by cd1833044ab7505bc101c85f59889bd3ea3fac80 where a function type would be converted to generic_poison even after being instantiated due to containing comptime only types. This could also be fixed by just checking `is_generic_instantiation` but this way also provides better type names. Closes #12625
2022-08-24stage2: explicitly tagged enums no longer have one possible valueAndrew Kelley
Previously, Zig had inconsistent semantics for an enum like this: `enum(u8){zero = 0}` Although in theory this can only hold one possible value, the tag `zero`, Zig no longer will treat the type this way. It will do loads and stores, as if the type has runtime bits. Closes #12619 Tests passed locally: * test-behavior * test-cases
2022-08-24Merge pull request #12623 from Vexu/stage2-fixesAndrew Kelley
Stage2 fixes
2022-08-24Merge pull request #12574 from Vexu/remove-bit-op-type-paramAndrew Kelley
stage2+stage1: remove type parameter from bit builtins
2022-08-24Sema: correctly reset inst_map for analyzeInlineCallArgVeikka Tuominen
Closes #12622
2022-08-24Sema: check one possible value earlier in `zirValidateArrayInit`Veikka Tuominen
Closes #12566
2022-08-24Sema: fix crash on slice of non-array typeVeikka Tuominen
Closes #12621
2022-08-24Sema: do not construct nested partial function typesVeikka Tuominen
Closes #12616
2022-08-22Sema: fix fieldCallBind on tuples and anon structsVeikka Tuominen
Closes #12573
2022-08-22stage2+stage1: remove type parameter from bit builtinsVeikka Tuominen
Closes #12529 Closes #12511 Closes #6835
2022-08-22Sema: fix implicit cast from extern fn to fn ptrVeikka Tuominen
Closes #12570
2022-08-22Sema: allow optional pointers in packed structsVeikka Tuominen
Closes #12572
2022-08-22Sema: make orelse with C pointers behave like stage1 for nowVeikka Tuominen
Closes #12537
2022-08-22Sema: resolve lazy values in `resolveMaybeUndefValIntable`Veikka Tuominen
Closes #12512 Closes #12513
2022-08-22Sema: fix parameter of type 'T' must be comptime errorVeikka Tuominen
Closes #12519 Closes #12505
2022-08-22Sema: check for astgen failures in `semaStructFields`Veikka Tuominen
The struct might be a top level struct in which case it might not have Zir. Closes #12548
2022-08-21Sema: ignore dbg_block instructions when checking for comptimenessVeikka Tuominen
Closes #12514
2022-08-21Sema: handle union and enum field order being differentVeikka Tuominen
Closes #12543
2022-08-21Sema: add note about function call being comptime because of comptime only ↵Veikka Tuominen
return type