Commit Graph

1809 Commits

Author SHA1 Message Date
Andrew Kelley
8c4784f9c1
remove no longer correct comment 2019-11-14 12:38:30 -05:00
LemonBoy
a11da37734 Update discriminant value also for zero-sized unions
Fixes #3681
2019-11-14 17:07:20 +00:00
Vexu
b83ce08a3b add compile error for @atomicRmw on enum not being an .Xchg 2019-11-13 18:48:31 +00:00
Andrew Kelley
0237e7a701 std.io.getStdOut and related fns no longer can error
Thanks to the Windows Process Environment Block, it is possible to
obtain handles to the standard input, output, and error streams without
possibility of failure.
2019-11-13 04:01:40 +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
f0c94d95dd
use @atomicStore in std lib 2019-11-13 00:52:15 +02:00
Vexu
110ef2e528
add @atomicStore builtin 2019-11-13 00:25:44 +02:00
Vexu
7e5b234b8b
support atomic operations with enums 2019-11-12 17:13:33 +02:00
Andrew Kelley
b9482fc32d
implement fully anonymous list literals 2019-11-11 19:00:39 -05:00
Andrew Kelley
a33b9aec72
add test for missing const in slice with nested array type 2019-11-11 18:01:27 -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
725b6ee634
add behavior test case for anonymous list literal syntax 2019-11-11 13:12:21 -05:00
Andrew Kelley
b4ad3e71af
add behavior test case for anon union literal 2019-11-11 13:12:21 -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
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
aa0daea541
update more of the std lib to use @as 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
e0db54e89d
update the codebase to use @as 2019-11-08 15:57:24 -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
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
c47211cc60 Prevent crash when slicing undefined ptr to slice
Fixes #3534
2019-11-04 20:33:41 +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
Andrew Kelley
61d5a0bf48
Merge branch 'std.net' 2019-10-30 21:30:16 -04:00
Andrew Kelley
6a15e8a7a7
add comments to disabled tests linking to the tracking issue 2019-10-30 21:29:45 -04:00
Tse
33cc204481 DragonFlyBSD support 2019-10-30 21:21:58 -04:00
Andrew Kelley
0de862e8ba
make std.net more portable
* Delete `std.net.TmpWinAddr`. I don't think that was ever meant to
   be a real thing.
 * Delete `std.net.OsAddress`. This abstraction was not helpful.
 * Rename `std.net.Address` to `std.net.IpAddress`. It is now an extern
   union of IPv4 and IPv6 addresses.
 * Move `std.net.parseIp4` and `std.net.parseIp6` to the
   `std.net.IpAddress` namespace. They now return `IpAddress` instead of
   `u32` and `std.net.Ip6Addr`, which is deleted.
 * Add `std.net.IpAddress.parse` which accepts a port and parses either
   an IPv4 or IPv6 address.
 * Add `std.net.IpAddress.parseExpectingFamily` which additionally
   accepts a `family` parameter.
 * `std.net.IpAddress.initIp4` and `std.net.IpAddress.initIp6` are
   improved to directly take the address fields instead of a weird
   in-between type.
 * `std.net.IpAddress.port` is renamed to `std.net.IpAddress.getPort`.
 * Added `std.net.IpAddress.setPort`.
 * `os.sockaddr` struct on all targets is improved to match the
   corresponding system struct. Previously I had made it a union of
   sockaddr_in, sockaddr_in6, and sockaddr_un. The new abstraction for
   this is now `std.net.IpAddress`.
 * `os.sockaddr` and related bits are added for Windows.
 * `os.sockaddr` and related bits now have the `zero` fields default
   to zero initialization, and `len` fields default to the correct size.
   This is enough to abstract the differences across targets, and so
   no more switch on the target OS is needed in `std.net.IpAddress`.
 * Add the missing `os.sockaddr_un` on FreeBSD and NetBSD.
 * `std.net.IpAddress.initPosix` now takes a pointer to `os.sockaddr`.
2019-10-30 20:22:05 -04:00
Andrew Kelley
32c89531b1
Add missing compile error when ptr used instead of array
in array literals.

Fixes #3524
2019-10-24 16:23:33 -04:00
Andrew Kelley
17eb24a7e4
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
  `@import("std").builtin`. The target-related types are moved
  to `std.Target`. This allows the data types to have methods, such as
  `std.Target.current.isDarwin()`.
 * `std.os.windows.subsystem` is moved to
   `std.Target.current.subsystem`.
 * Remove the concept of the panic package from the compiler
   implementation. Instead, `std.builtin.panic` is always the panic
   function. It checks for `@hasDecl(@import("root"), "panic")`,
   or else provides a default implementation.

This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 19:09:49 -04:00
Andrew Kelley
e98e5dda52
implement safety for resuming non-suspended function
closes #3469
2019-10-22 23:43:27 -04:00
Andrew Kelley
e839250c51
Merge branch 'stratact-no-dir-allocators'
closes #2885
closes #2886
closes #2888
closes #3249
2019-10-21 23:54:29 -04:00
Andrew Kelley
064377be9a
test runner: restore previous behavior of printing all tests passed 2019-10-21 22:21:18 -04:00