Commit Graph

6508 Commits

Author SHA1 Message Date
Veikka Tuominen
eeec34ccb6 Sema: implement comptime error return traces 2024-01-22 18:08:56 -08:00
MrDmitry
e72f1d5ae7 Extend test cases
Add tests for:
- packed neighboring variables
- separated neighboring variables
- mixed types of neighboring variables
2024-01-21 03:18:37 -05:00
Veikka Tuominen
2e7d28dd0d Sema: replace uses of toUnsignedInt with toUnsignedIntAdvanced
During semantic analysis the value may be an unresolved lazy value
which makes using `toUnsignedInt` invalid.

Add assertions to detect similar issues in the future.

Closes #18624
2024-01-20 12:21:05 -08:00
David Rubin
1b8f7e46fa
AstGen: detect duplicate field names
This logic was previously in Sema, which was unnecessary complexity, and meant the issue was not detected unless the declaration was semantically analyzed. This commit finishes the work which 941090d started.

Resolves: #17916
2024-01-20 17:23:47 +00:00
Meghan Denny
46d592e485 do not enforce function parameters to be marked comptime if only called at comptime 2024-01-19 15:31:18 -08:00
David Rubin
100efcf8d3
return optional state to zirPtrCastNoDest 2024-01-19 21:25:05 +02:00
Andrew Kelley
6ecf3b1ef3
Merge pull request #18599 from dweiller/err-union-switch-err-trace
astgen: fix error return trace on error union switch
2024-01-18 18:32:52 -08:00
dweiller
c4cff443b8 test/stack_traces.zig: add err union switch case 2024-01-18 15:10:32 +11:00
David Rubin
6e5bdb5397
add type check to zirSwitchBlockErrUnion 2024-01-18 00:46:00 +00:00
Techatrix
ec358d6db5 sema: fix safe integer arithmetic operations on undefined values
Previously `@as(i64, undefined) +% 1` would produce `@as(@TypeOf(undefined), undefined)` which now gives `@as(i64, undefined)`.
Previously `@as(i64, undefined) +| 1` would hit an assertion which now gives `@as(i64, undefined)`.
2024-01-16 16:27:31 -08:00
travisstaloch
f3353708d8
AstGen: use correct token_src for switch, if and while exprs
fixes #18579
2024-01-16 18:22:44 +02:00
february cozzocrea
da506aaf6e
translate-c: Explicit cast bool from float fix 2024-01-16 18:12:05 +02:00
february cozzocrea
50457482b1
translate-c: Fix for compound assign implicit cast error 2024-01-16 17:57:31 +02:00
Andrew Kelley
fe870418b1
Merge pull request #18584 from Techatrix/fix-switch-on-err
fix ast gen failure to catch incorrect by ref error captures
2024-01-16 02:42:06 -08:00
Andrew Kelley
ca8c6dd4d6
Merge pull request #18569 from dweiller/17944-followup
17944 followup
2024-01-15 22:59:33 -08:00
Techatrix
06410f58bd AstGen: properly handle ill-formed switch on error 2024-01-16 05:55:26 +01:00
Techatrix
8b9425c248 AstGen: add error message for capture error by ref in switch on error 2024-01-16 05:55:26 +01:00
dweiller
a219c9faaa test/behavior: fix test type check for multi-ptr slice
The original test was checking the types of irrelevant slices, the test
is for slicing of multi-pointers _without_ an end value, but the types
of slices with an end value were being checked.
2024-01-15 20:55:01 +11:00
dweiller
8108c9f4d2 test/behavior: replace all 'comptime expect' with 'comptime assert' 2024-01-15 20:55:01 +11:00
Andrew Kelley
32e88251e4 update test case for new const/var compile error
commit 8afafa717f was created when this
error did not exist yet.
2024-01-15 01:53:41 -07:00
Jacob Young
03ed3f56cf Sema: fix @extern decls
Closes #18550
2024-01-15 07:39:05 +01:00
Jakub Konka
3dddb881bf
Merge pull request #18560 from ziglang/elf-report-dupes
elf: report duplicate symbol definitions
2024-01-15 07:37:09 +01:00
dweiller
8afafa717f sema: allow slicing *T with comptime known [0..1] 2024-01-14 17:26:45 -08:00
Jakub Konka
b1ffc2b8b3 test/link/elf: patch up relocatable test 2024-01-15 00:18:50 +01:00
Jakub Konka
d7c2324cdb test/link/elf: trigger build system bug testing relocatable mode 2024-01-14 20:51:03 +01:00
jimying
89d4ac6289 Fix minor error: std.ChildProcess.exec() already rename to run() 2024-01-13 23:23:39 -08:00
Andrew Kelley
bd46410419 Revert "Merge pull request #18410 from dweiller/by-length-slice-bug"
This reverts commit d9d840a33a, reversing
changes made to a04d433094.

This is not an adequate implementation of the missing safety check, as
evidenced by the changes to std.json that are reverted in this commit.

Reopens #18382
Closes #18510
2024-01-13 23:21:44 -07:00
Nameless
b723296e1f std.http: add missing documentation and a few examples 2024-01-13 18:51:38 -08:00
Meghan Denny
3d6c26525f sema: forbid asm output to const locals 2024-01-12 16:23:42 -08:00
Andrew Kelley
30688c341b LLVM: fix lowering of extern anyopaque
closes #18461
2024-01-11 01:00:49 -08:00
february cozzocrea
aafff25897
translate-c: float cast from boolean expr fix 2024-01-10 19:13:11 +00:00
Bogdan Romanyuk
4a1a5ee47b
AstGen: add error for redundant comptime var in comptime scope (#18242) 2024-01-09 20:09:39 -05:00
Andrew Kelley
7320b24e0e
Merge pull request #18486 from castholm/undefined-version
Add support for `--(no-)undefined-version`
2024-01-09 14:23:31 -08:00
Carl Åstholm
3cd646869b Add tests for --undefined-version 2024-01-09 17:26:10 +01:00
dweiller
ec5b751373 sema: inherit block want_safety for err switch union 2024-01-09 14:42:12 +11:00
dweiller
69ab687156 test: add tests for switch_block_err_union 2024-01-09 14:42:12 +11:00
Andrew Kelley
3176fdc0b9
Merge pull request #18470 from castholm/typeInfo-sentinels
Make `@typeInfo` return null-terminated strings
2024-01-07 22:28:24 -08:00
Veikka Tuominen
faeb0ef032 llvm: optional slices cannot be passed in parts when they allowzero
Closes #18428
2024-01-08 06:57:06 +02:00
Andrew Kelley
3f6e651d5a remove tool: update-license-headers
This tool is not needed since license headers were removed in
d29871977f.
2024-01-07 17:02:17 -07:00
Carl Åstholm
92458094c8 Fix failing type reifications 2024-01-07 16:27:50 +01:00
Veikka Tuominen
804cee3b93 categorize behavior/bugs/<issueno>.zig tests 2024-01-06 16:49:41 -08:00
Pat Tullmann
cbaaf6477f test glibc_runtime_check: add strlcpy() check
The strlcpy symbol was added in v2.38, so this is a handy symbol for
creating binaries that won't run on relatively modern systems (e.g., mine,
that has glibc 2.36 installed).
2024-01-04 17:12:07 -07:00
Pat Tullmann
42d7b69d81 test/link/glibc_compat: test various older glibc versions
Compile, link and run a test case against various glibc versions.
Exercise symbols that have been probelmatic in the past.
2024-01-04 17:12:07 -07:00
Abhinav Gupta
d3a163f868
build/LazyPath: Add dirname (#18371)
Adds a variant to the LazyPath union representing a parent directory
of a generated path.

```zig
const LazyPath = union(enum) {
    generated_dirname: struct {
        generated: *const GeneratedFile,
        up: usize,
    },
    // ...
}
```

These can be constructed with the new method:

```zig
pub fn dirname(self: LazyPath) LazyPath
```

For the cases where the LazyPath is already known
(`.path`, `.cwd_relative`, and `dependency`)
this is evaluated right away.
For dirnames of generated files and their dirnames,
this is evaluated at getPath time.

dirname calls can be chained, but for safety,
they are not allowed to escape outside a root
defined for each case:

- path: This is relative to the build root,
  so dirname can't escape outside the build root.
- generated: Can't escape the zig-cache.
- cwd_relative: This can be a relative or absolute path.
  If relative, can't escape the current directory,
  and if absolute, can't go beyond root (/).
- dependency: Can't escape the dependency's root directory.

Testing:
I've included a standalone case for many of the happy cases.
I couldn't find an easy way to test the negatives, though,
because tests cannot yet expect panics.
2024-01-04 18:47:28 -05:00
Carl Åstholm
501a2350ab sema: Prevent reifying non-empty union with empty tag type 2024-01-04 22:38:31 +02:00
Andrew Kelley
9a16085093
Merge pull request #18376 from amp-59/shl_exact_comptime_int_to_shl
Sema: Updated `zirShl` to compute `shl_exact` with `comptime_int` LHS using `shl`
2024-01-04 04:19:26 -08:00
Andrew Kelley
fc79b22a98
Merge pull request #17431 from castholm/expectEqual
Update `std.testing.expectEqual` and friends to use peer type resolution
2024-01-03 23:55:59 -08:00
Andrew Kelley
52ebba6bdf @shlExact fixups
* Add clarification in langref
* move test case to behavior tests
2024-01-04 00:44:44 -07:00
amp-59
10016e0368 Sema: fix crash compiling @shlExact
Updated `zirShl`, to compute `shl_exact` with `comptime_int` LHS operand
like `shl`, and added test case for `@shlExact` with `comptime_int` LHS
operand.
2024-01-04 00:10:41 -07:00
Andrew Kelley
a9337bef2d
Merge pull request #18431 from jacobly0/cbe-extern
cbe: fix non-msvc externs and exports
2024-01-03 12:57:01 -08:00