688 Commits

Author SHA1 Message Date
Veikka Tuominen
1c4c68e6ba AstGen: use reachableExpr for try operand
Closes #12248
2022-09-02 17:57:10 +03:00
Veikka Tuominen
2cd3989cb3 Sema: add more validation to coerceVarArgParam
Closes #12706
2022-09-01 13:16:33 +03:00
Veikka Tuominen
d3b4b2edf1 Sema: shift of comptime int with runtime value
Closes #12290
2022-08-30 12:22:07 -07:00
Veikka Tuominen
01d19a8d3c Sema: do not emit generic poison for non generic parameters
Closes #12679
2022-08-30 12:22:07 -07:00
Veikka Tuominen
67a44211f7 Sema: improve handling of always_tail call modifier
Closes #4301
Closes #5692
Closes #6281
Closes #10786
Closes #11149
Closes #11776
2022-08-30 12:22:07 -07:00
Veikka Tuominen
a4b52ccd9f Sema: fix access of inactive union field when enum and union fields are in different order
Closes #12667
2022-08-29 13:45:37 -07:00
Veikka Tuominen
6aead18ab3 add error tests for now correctly behaving cases
Closes #6377
2022-08-28 15:41:21 +03:00
Veikka Tuominen
1401890ed5 Sema: add error for switch on slice
Closes #12651
2022-08-28 15:41:21 +03:00
Veikka Tuominen
fc213e2d61 AstGen: add error for named function type
Closes #12660
2022-08-28 15:41:21 +03:00
antlilja
ae8d26a6a0 Sema: add error for non-comptime param in comptime func
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-27 11:17:48 +03:00
Veikka Tuominen
4405188cf7 Sema: ignore comptime params in partial func type check
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-25 16:29:23 +03:00
Andrew Kelley
7a881435ed
Merge pull request #12623 from Vexu/stage2-fixes
Stage2 fixes
2022-08-24 15:59:46 -04:00
Andrew Kelley
2a96209c40
Merge pull request #12574 from Vexu/remove-bit-op-type-param
stage2+stage1: remove type parameter from bit builtins
2022-08-24 15:57:44 -04:00
Veikka Tuominen
69a3c4e279 Sema: correctly reset inst_map for analyzeInlineCallArg
Closes #12622
2022-08-24 21:31:02 +03:00
Veikka Tuominen
1d0b729f28 Sema: fix crash on slice of non-array type
Closes #12621
2022-08-24 21:31:02 +03:00
Veikka Tuominen
cd1833044a Sema: do not construct nested partial function types
Closes #12616
2022-08-24 21:31:02 +03:00
Veikka Tuominen
5404dcdfd8 Sema: fix fieldCallBind on tuples and anon structs
Closes #12573
2022-08-22 14:31:58 +03:00
Veikka Tuominen
62ff8871ed stage2+stage1: remove type parameter from bit builtins
Closes #12529
Closes #12511
Closes #6835
2022-08-22 11:19:20 +03:00
Veikka Tuominen
b55a5007fa Sema: fix parameter of type 'T' must be comptime error
Closes #12519
Closes #12505
2022-08-22 11:16:36 +03:00
Veikka Tuominen
e8102d8738 Sema: add note about function call being comptime because of comptime only return type 2022-08-21 12:24:48 +03:00
zooster
4055e6055b
AstGen: disallow leading zeroes in int literals and int types
This makes `0123` and `u0123` etc. illegal.

I'm now confident that this is a good change because
I actually caught two C header translation mistakes in `haiku.zig` with this.
Clearly, `0123` being octal in C (TIL) can cause confusion, and we make this easier to read by
requiring `0o` as the prefix and now also disallowing leading zeroes in integers.

For consistency and because it looks weird, we disallow it for integer types too (e.g. `u0123`).

Fixes #11963
Fixes #12417
2022-08-18 19:54:51 +03:00
Veikka Tuominen
b038dba06b
Merge pull request #12462 from Vexu/stage2-noreturn
Stage2: improve behavior of noreturn
2022-08-18 17:18:57 +03:00
Andrew Kelley
2cccd14491 fix typo in compile error message 2022-08-17 14:09:42 -07:00
Veikka Tuominen
59b6483d63 add test 2022-08-17 14:09:42 -07:00
Veikka Tuominen
233049503a Sema: allow empty enums and unions 2022-08-17 23:03:04 +03:00
Veikka Tuominen
c3d5428cba Sema: properly handle noreturn fields in unions 2022-08-17 22:07:48 +03:00
Veikka Tuominen
b0a55e1b3b Sema: make noreturn error union behave correctly 2022-08-17 20:10:18 +03:00
Veikka Tuominen
db0f372da8 Sema: make optional noreturn behave correctly 2022-08-17 20:10:18 +03:00
Veikka Tuominen
9d4561ef00 AstGen: detect declarations shadowing locals
Closes #9355
2022-08-16 20:35:03 +03:00
LeRoyce Pearson
cb901e578c
stage2: add compile errors for comptime @shrExact and @divExact failures 2022-08-15 11:28:42 +03:00
martinhath
92568a0097
Sema: add error for signed integer division
stage1 error reads

error: division with 'i32' and 'comptime_int': signed integers must use @divTrunc, @divFloor, or @divExact

Fixes: #12339
2022-08-12 11:45:11 +03:00
Andrew Kelley
e0178890ba
Merge pull request #12379 from ifreund/packed-struct-explicit-backing-int
stage2: Implement explicit backing integers for packed structs
2022-08-10 19:13:29 -04:00
InKryption
e218b7ea0c stage2: add compile error for invalid null/undefined pointer cast 2022-08-10 16:39:46 -04:00
LeRoyce Pearson
0e118ed0ac stage2: add compile error for shlExact overflow
- moves a stage1 test case and makes it target `llvm` backend instead
  of `stage1` backend
2022-08-10 16:14:30 -04:00
Isaac Freund
0d32b73078
stage2: Implement explicit backing integers for packed structs
Now the backing integer of a packed struct type may be explicitly
specified with e.g. `packed struct(u32) { ... }`.
2022-08-10 19:54:45 +02:00
Veikka Tuominen
b757a96d5c Sema: add declared here note to function call errors 2022-08-09 23:37:26 +03:00
Veikka Tuominen
0fd90749d1 stage2: generate call arguments in separate blocks 2022-08-09 16:19:55 +03:00
Veikka Tuominen
c76b5c1a31 stage2: correct node offset of nested declarations 2022-08-09 11:59:10 +03:00
Veikka Tuominen
d769fd0102 stage2: pass anon name strategy to reify 2022-08-08 18:28:39 -07:00
Andrew Kelley
11c715cd5a remove brittle test case
see #12358
2022-08-07 16:07:21 -07:00
Anton Lilja
86d9c3de2b
Sema: fix infinite recursion in explainWhyTypeIsComptime
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-06 14:17:09 +03:00
Veikka Tuominen
4ab60dc18b Sema: add error for dependency loops 2022-08-03 17:10:39 +03:00
Veikka Tuominen
b79929b2ea AstGen: better source location for if/while condition unwrapping 2022-08-03 16:45:33 +03:00
Veikka Tuominen
d1d24b426d AstGen: check loop bodies and else branches for unused result 2022-08-03 16:45:33 +03:00
Veikka Tuominen
aa78ebaf95 Sema: improve circular dependency errors 2022-08-03 16:45:33 +03:00
Veikka Tuominen
02112f8836 AstGen: add error for break/continue out of defer expression 2022-08-03 16:45:33 +03:00
Veikka Tuominen
6547c3887e Sema: add error for closure capture at runtime 2022-08-03 16:45:33 +03:00
Veikka Tuominen
14f0b70570 Sema: add safety for sentinel slice 2022-08-02 18:34:30 +03:00
Veikka Tuominen
e47706f344 Sema: validate packed struct field types 2022-08-01 23:59:40 +03:00
Veikka Tuominen
f1768b40b2 stage2: better source location for var decls 2022-08-01 23:37:01 +03:00