Commit Graph

3362 Commits (4830415071c3d62e4e2c19e5f5342151632e72bb)

Author SHA1 Message Date
Vexu b83ce08a3b add compile error for @atomicRmw on enum not being an .Xchg 2019-11-13 18:48:31 +00:00
Andrew Kelley 8bae70454d
Merge pull request #3675 from Vexu/atomic-store
Add @atomicStore builtin
2019-11-13 03:06:55 +00:00
Andrew Kelley 32b37e695a
fix anonymous struct literal assigned to variable
closes #3667
2019-11-12 21:57:25 -05:00
Andrew Kelley 37318bf151
fn parameters participate in result location semantics
See #3665
2019-11-12 18:55:17 -05:00
Vexu 41914321b4
fix comptime atomicStore and add tests 2019-11-13 01:32:16 +02:00
Vexu 110ef2e528
add @atomicStore builtin 2019-11-13 00:25:44 +02:00
Andrew Kelley e32b4829f4
Merge pull request #3670 from Vexu/atomics-enum
Support atomic operations with enums
2019-11-12 17:45:29 +00:00
Andrew Kelley 710ccacfa3
fix assertion failure in ptrToInt
found by building pluto
2019-11-12 12:21:20 -05:00
Vexu 7e5b234b8b
support atomic operations with enums 2019-11-12 17:13:33 +02:00
Andrew Kelley 45d2fd9b9d
fix assertion failure in init_const_undefined
found this from building my tetris game
2019-11-11 22:11:28 -05:00
Andrew Kelley bf8870a60b
fix unresolved type making it to codegen
found this trying to build oxid
2019-11-11 22:11:22 -05:00
Andrew Kelley b9482fc32d
implement fully anonymous list literals 2019-11-11 19:00:39 -05:00
Andrew Kelley ca2a788a24
fully anonymous struct literals 2019-11-11 17:50:41 -05:00
Andrew Kelley 1bca8e693d
fix anon literal used with return result loc 2019-11-11 13:18:16 -05:00
Andrew Kelley 5b27943498
implement anon struct literal syntax
This implements stage1 parser support for anonymous struct literal
syntax (see #685), as well as semantic analysis support for anonymous
struct literals and anonymous list literals (see #208). The semantic
analysis works when there is a type coercion in the result location;
inferring the struct type based on the values in the literal is not
implemented yet. Also remaining to do is zig fmt support for this new
syntax and documentation updates.
2019-11-11 13:11:58 -05:00
Andrew Kelley de30438ed2
stage1 parser code for anon container lit 2019-11-11 13:11:58 -05:00
Andrew Kelley ae0a219d1f
stop accepting deprecated `use` keyword
closes #2591
2019-11-11 13:02:39 -05:00
LemonBoy d18b5f8b53 Fix initialization of union references
Fixes #3532
2019-11-09 12:20:34 -05:00
Andrew Kelley 3cf5c2c62b
fix regressed tests and update docs to use "type coercion" 2019-11-08 15:57:25 -05:00
Andrew Kelley 3834d3dac0
passing std lib tests 2019-11-08 15:57:25 -05:00
Andrew Kelley a2acc27872
behavior tests passing 2019-11-08 15:57:25 -05:00
Andrew Kelley 8954a1bae5
more regressions fixed 2019-11-08 15:57:25 -05:00
Andrew Kelley fa34dfcce7
fix result loc of cast not finding parent 2019-11-08 15:57:24 -05:00
Andrew Kelley 2a6fbbd8fb
introduce `@as` builtin for type coercion
This commit also hooks up type coercion (previously called implicit
casting) into the result location mechanism, and additionally hooks up
variable declarations, maintaining the property that:

    var a: T = b;

is semantically equivalent to:

    var a = @as(T, b);

See #1757
2019-11-08 15:57:24 -05:00
Shawn Landden 2e52fafac5 correctly use llvm undef in release modes 2019-11-07 02:51:04 -05:00
LemonBoy 528908a06e
Fix ptrCast of array references to fn
Closes #3607
2019-11-07 02:46:10 -05:00
Andrew Kelley 6ee3cabe5c
allow type coercion from *[0]T to E![]const T
This is an unambiguous, safe cast.
2019-11-06 20:44:15 -05:00
Vexu ac6f0d245d fix NodeErrorSetDecl rendering 2019-11-06 18:15:39 -05:00
Brendan Hansknecht c1e8fdf812 add token for parsing pointer dereference 2019-11-06 14:03:21 -05:00
Vexu 6b61fcddfa fix translate-c arrow deref 2019-11-06 13:58:55 -05:00
Andrew Kelley 9a08de93b6
fix incorrect type name on bit field pointers 2019-11-05 13:37:43 -05:00
Andrew Kelley 9b4a529164
fix initialization of vector in a struct field 2019-11-05 12:36:39 -05:00
Andrew Kelley cbaa10fc3b
implement storing vector elements via runtime index 2019-11-05 12:11:57 -05:00
Andrew Kelley 70be308c43
implement loading vector elements via runtime index 2019-11-05 12:11:40 -05:00
Andrew Kelley 76d188551e
implement store of vector element with comptime index 2019-11-05 12:11:18 -05:00
Andrew Kelley ece8d6c2fa
comptime load of vector element 2019-11-05 12:11:18 -05:00
Andrew Kelley 55e54d98c4
runtime load vector element with comptime index 2019-11-05 12:11:16 -05:00
LemonBoy 71e209521a Mark type fields as CT
Fixes #3276
2019-11-05 12:05:01 -05:00
LemonBoy 9170dcb73f Fix #3558
Finding a suitable test case is left as an exercise to the reader.
2019-11-04 20:33:41 +01:00
LemonBoy c47211cc60 Prevent crash when slicing undefined ptr to slice
Fixes #3534
2019-11-04 20:33:41 +01:00
LemonBoy 2b4bf1e7ce Fix crash in #3483
The bytesToSlice is still not evaluated at comptime but at least it
doesn't crash anymore.
2019-11-04 20:33:40 +01:00
LemonBoy 61825062aa Correctly process errors for invalid types in fn call
Fixes #3544
2019-11-04 20:33:40 +01:00
LemonBoy 2f740fa19f Fix cmpxchg trying to execute at CT
Fixes #3582
2019-11-04 09:54:13 +01:00
Michael Dusan 10046f9a52 stage1: add linux XDG Base Directory support
- define zig global cache based on XDG spec:

    if env XDG_CACHE_HOME {
        "$XDG_CACHE_HOME/zig"
    } else {
        "$HOME/.cache/zig"
    }

- old definition "$HOME/.local/share/zig" is retired
- closes #3573
2019-11-02 18:30:07 -04:00
Andrew Kelley 790d439ce2
util.cpp: canonicalize the order of includes 2019-10-31 13:47:20 -04:00
Andrew Kelley 61d5a0bf48
Merge branch 'std.net' 2019-10-30 21:30:16 -04:00
Tse 33cc204481 DragonFlyBSD support 2019-10-30 21:21:58 -04:00
Andrew Kelley b3c80418a8
fix regression in behavior tests 2019-10-30 00:40:17 -04:00
Andrew Kelley c3d816a98e
std lib networking improvements, especially non-blocking I/O
* delete the std/event/net directory
 * `std.event.Loop.waitUntilFdReadable` and related functions
   no longer have possibility of failure. On Linux, they fall
   back to poll() and then fall back to sleep().
 * add some missing `noasync` decorations in `std.event.Loop`
 * redo the `std.net.Server` API. it's quite nice now, but
   shutdown does not work cleanly. There is a race condition with
   close() that I am actively working on.
 * move `std.io.OutStream` to its own file to match `std.io.InStream`.
   I started working on making `write` integrated with evented I/O,
   but it got tricky so I backed off and filed #3557. However
   I did integrate `std.os.writev` and `std.os.pwritev` with evented I/O.
 * add `std.Target.stack_align`
 * move networking tests to `lib/std/net/test.zig`
 * add `std.net.tcpConnectToHost` and `std.net.tcpConnectToAddress`.
 * rename `error.UnknownName` to `error.UnknownHostName` within the
   context of DNS resolution.
 * add `std.os.readv`, which is integrated with evented I/O.
 * `std.os.preadv`, is now integrated with evented I/O.
 * `std.os.accept4` now asserts that ENOTSOCK and EOPNOTSUPP never
    occur (misuse of API), instead of returning errors.
 * `std.os.connect` is now integrated with evented I/O.
   `std.os.connect_async` is gone. Just use `std.os.connect`.
 * fix false positive dependency loop regarding async function frames
 * add more compile notes to help when dependency loops occur
   in determining whether a function is async.
 * ir: change an assert to ir_assert to make it easier to find
   workarounds for when such an assert is triggered. In this case
   it was trying to parse an IPv4 address at comptime.
2019-10-29 22:59:30 -04:00
Andrew Kelley 4f594527c0
detect async fn recursion and emit compile error 2019-10-28 15:10:48 -04:00