Andrew Kelley
d353d5aef8
fix @bytesToSlice on a packed struct
...
closes #1551
2018-09-18 09:49:57 -04:00
Josh Wolfe
13645585fe
link to #1544
2018-09-17 21:25:37 -04:00
Josh Wolfe
d7492b2c22
somewhat realistic usecase test for shifting strange integer sizes
2018-09-17 20:49:23 -04:00
Andrew Kelley
bfcfaaf5bd
fix codegen for @intCast to u0
2018-09-17 20:33:42 -04:00
Andrew Kelley
b16229da1d
add compile error for @ptrCast 0 bit type to non-0 bit type
2018-09-17 19:41:11 -04:00
Andrew Kelley
78a9a465a3
add compile error for non-optional types compared against null
...
closes #1539
2018-09-17 18:58:50 -04:00
Andrew Kelley
6c71e9a54d
fix crash when bit shifting a u1
2018-09-17 18:44:45 -04:00
Andrew Kelley
cf9200b815
dereferencing a *u0 is comptime-known to be 0
2018-09-17 18:13:38 -04:00
Andrew Kelley
4c6f1e614a
remove `zig build --init`. add `zig init-lib` and `zig init-exe`
...
init-lib creates a working static library with tests, and
init-exe creates a working hello world with a `run` target.
both now have test coverage with the new "cli tests" file.
closes #1035
2018-09-17 17:11:18 -04:00
Andrew Kelley
9c9eefc841
allow extern structs to have stdcallcc function pointers
...
closes #1536
2018-09-17 11:22:30 -04:00
Andrew Kelley
dd5b2d1b04
fix crash when pointer casting a runtime extern function
2018-09-16 11:23:38 -04:00
Andrew Kelley
3f776af3fa
fix alignment of structs
...
closes #1248
closes #1052
closes #1154
2018-09-14 19:08:59 -04:00
Wink Saville
82af31ce36
Fix additional regressions calling FileOutStream/FileInStream init()
...
This is caused by change 686663239a
and not
fixed in 832caefc2a
.
2018-09-14 12:07:21 -04:00
Andrew Kelley
3d38feded9
fix tagged union with all void payloads but meaningful tag
...
closes #1322
2018-09-14 00:38:22 -04:00
Andrew Kelley
1e03cf1739
fix assertion failure on compile-time `@intToPtr` of function
2018-09-13 19:12:25 -04:00
Andrew Kelley
c06a61e9bf
remove `this`. add `@This()`.
...
closes #1283
2018-09-13 16:34:33 -04:00
Andrew Kelley
7c3636aaa3
remove the scope parameter of setFloatMode
...
also document that scopes inherit this value. See #367
See #1283
2018-09-13 15:46:34 -04:00
Andrew Kelley
ac0cda8df8
add compile error for merging non- error sets
...
closes #1509
2018-09-13 13:48:41 -04:00
Andrew Kelley
22e39e1e5a
fix tagged union with only 1 field tripping assertion
...
closes #1495
now the tag type of an enum with only 1 item is comptime_int.
2018-09-13 13:33:11 -04:00
Andrew Kelley
7dd3c3814d
fix incorrect error union const value generation
...
closes #1442
zig needed to insert explicit padding into this structure before
it got bitcasted.
2018-09-11 15:16:50 -04:00
Andrew Kelley
dd1338b0e6
fix incorrect union const value generation
...
closes #1381
The union was generated as a 3 byte struct when it needed to be
4 bytes so that the packed struct bitcast could work correctly.
Now it recognizes this situation and adds padding bytes to become
the correct size so that it can fit into an array.
2018-09-11 12:59:39 -04:00
Andrew Kelley
52f4e934a9
fix llvm assertion and missing compile error
2018-09-10 22:44:27 -04:00
Andrew Kelley
9c169f3cf7
C ABI: support returning large structs on x86_64
...
also panic instead of emitting bad code for returning small structs
See #1481
2018-09-07 20:09:33 -04:00
Andrew Kelley
9017efee22
C ABI: support medium size structs & unions for x86_64 params
...
See #1481
2018-09-07 18:51:34 -04:00
raulgrell
09a1162af5
builtin functions: @byteOffsetOf and @bitOffsetOf
2018-09-07 22:49:19 +01:00
Andrew Kelley
b18af37c57
fix crash when var init has compile error
...
and then the var is referenced
closes #1483
2018-09-07 15:17:24 -04:00
Andrew Kelley
743b2e4afc
add C ABI test for big unions
2018-09-07 13:51:11 -04:00
Andrew Kelley
be6cccb3a5
stage1: c abi for big struct works
2018-09-07 11:52:57 -04:00
Andrew Kelley
a9a925e500
add C ABI tests
2018-09-06 16:29:35 -04:00
Andrew Kelley
6632d85e5f
stage1: improve handling of generic fn proto type expr
...
closes #902
2018-09-05 21:21:59 -04:00
Andrew Kelley
1d8b8ad687
add compile error for using outer scoped runtime variables
...
from a fn defined inside it. closes #876
2018-09-05 20:32:06 -04:00
Andrew Kelley
a3d384e593
add test case for #726
2018-09-05 18:20:04 -04:00
Andrew Kelley
b517bea734
allow comptime_int to @floatToInt
2018-09-05 18:01:48 -04:00
hfcc
768d1fc539
Added compilation error when a non-float is given to @floatToInt()
2018-09-05 23:31:25 +02:00
Andrew Kelley
ffb3b1576b
stage1: fix tagged union with no payloads
...
closes #1478
2018-09-05 16:19:58 -04:00
Andrew Kelley
c87a576cb5
stage1 compile error instead of crashing for unsupported comptime ptr cast
...
See #955
2018-09-05 15:53:36 -04:00
Andrew Kelley
a76a72469b
stage1: fix crash when invalid type used in array type
...
closes #1186
2018-09-05 10:43:35 -04:00
Andrew Kelley
869167fc6d
compile error for @noInlineCall on an inline fn
...
closes #1133
2018-09-04 17:38:48 -04:00
Andrew Kelley
68db9d5074
add compile error for comptime control flow inside runtime block
...
closes #834
2018-09-04 15:28:35 -04:00
Andrew Kelley
e82cd53df4
fix incorrect value for inline loop
...
09cc1dc660
failed to handle mem_slot_index correctly
closes #1436
2018-09-03 21:24:20 -04:00
Andrew Kelley
95636c7e5f
ability to @ptrCast to *void
...
fixes #960
2018-09-03 00:04:12 -04:00
Andrew Kelley
832caefc2a
fix regressions
2018-09-02 18:35:32 -04:00
Andrew Kelley
b65cca37ce
add test coverage for invalid switch expression parameter
...
closes #604
2018-08-28 15:48:39 -04:00
Andrew Kelley
901b5c1566
add compile error for function prototype with no body
...
closes #1231
2018-08-28 15:39:32 -04:00
Andrew Kelley
09cc1dc660
fix crash when var in inline loop has different types
...
closes #917
closes #845
closes #741
closes #740
2018-08-28 15:24:28 -04:00
Andrew Kelley
45d9d9f953
minor fixups
2018-08-27 18:31:28 -04:00
raulgrell
e2a9f2ef98
Allow implicit cast from *T and [*]T to ?*c_void
2018-08-27 23:13:57 +01:00
Andrew Kelley
009e90f446
fix @typeInfo unable to distinguish compile error vs no-payload
...
closes #1421
closes #1426
2018-08-27 17:13:34 -04:00
Andrew Kelley
526d8425ab
fix false negative determining if function is generic
...
This solves the smaller test case of #1421 but the
other test case is still an assertion failure.
2018-08-27 16:14:48 -04:00
Andrew Kelley
4b68ef45af
fix incorrectly generating an unused const fn global
...
closes #1277
2018-08-22 14:31:30 -04:00
Raul Leal
87b10400c2
allow implicit cast from *[N]T to ?[*]T ( #1398 )
...
* allow implicit cast from *[N]T to ?[*]T
2018-08-22 13:12:08 -04:00
Andrew Kelley
02ba4b1678
Merge branch 'master' into shawnl-path_max
2018-08-21 20:56:28 -04:00
Andrew Kelley
b2917e6be0
Revert "Merge branch 'mtn-translate-c-enum-vals'"
...
This reverts commit 937b822fa9
, reversing
changes made to dd4b13ac03
.
Tests failing on Windows.
Re-opens #1360
2018-08-21 20:50:03 -04:00
Andrew Kelley
ea1b21dbdb
fix linux
...
* error.BadFd is not a valid error code. it would always be a bug to
get this error code.
* merge error.Io with existing error.InputOutput
* merge error.PathNotFound with existing error.FileNotFound.
Not all OS's support both.
* add os.File.openReadC
* add error.BadPathName for windows file operations with invalid
characters
* add os.toPosixPath to help stack allocate a null terminating byte
* add some TODOs for other functions to investigate removing the
allocator requirement
* optimize some implementations to use the alternate functions when
a null byte is already available
* add a missing error.SkipZigTest
* os.selfExePath uses a non-allocating API
* os.selfExeDirPath uses a non-allocating API
* os.path.real uses a non-allocating API
* add os.path.realAlloc and os.path.realC
* convert many windows syscalls to use the W versions (See #534 )
2018-08-21 20:31:50 -04:00
kristopher tate
b023db2e82
src/translate_c.cpp: correctly bridge llvm::APSInt with Zig BigInt;
...
ACHTUNG: llvm::APSInt stores an int's sign inside of its getRawData; Internally to Zig we store an integer's sign outside of getRawData! (~aps_int) calls .flip() internally on the raw data to match Zig.
test/translate_c.zig: enum: add wider range of values (u64) to try;
2018-08-20 22:46:11 -04:00
Michael Noronha
7e7e59d881
translate-c: Correctly translate enum init values, addressing #1360
2018-08-20 22:45:19 -04:00
Andrew Kelley
dd4b13ac03
Revert "translate-c: Correctly translate enum init values, addressing #1360 ( #1377 )"
...
This reverts commit b8ce8f219c
.
Squashing the commits from the pull request resulted in kristopher tate
from being omitted from the authors. A future commit will merge
the code correctly.
2018-08-20 22:39:39 -04:00
Michael Noronha
b8ce8f219c
translate-c: Correctly translate enum init values, addressing #1360 ( #1377 )
...
* translate-c: Correctly translate enum init values
* translate-c: Test enum initialization
* translate-c: Flip to positive using APSInt builtins
* src/translate_c.cpp: correctly bridge llvm::APSInt with Zig BigInt;
ACHTUNG: llvm::APSInt stores an int's sign inside of its getRawData; Internally to Zig we store an integer's sign outside of getRawData! (~aps_int) calls .flip() internally on the raw data to match Zig.
* test/translate_c.zig: enum: add wider range of values (u64) to try;
closes #1360
2018-08-20 14:29:26 -04:00
Andrew Kelley
63a23e848a
translate-c: fix for loops with var init and empty body
2018-08-05 18:40:14 -04:00
Andrew Kelley
387fab60a6
translate-c: fix do while with empty body
2018-08-05 18:32:38 -04:00
Andrew Kelley
c420b234cc
translate-c: handle for loop with empty body
2018-08-05 18:18:24 -04:00
Andrew Kelley
aa232089f2
translate-c: fix while loop with no body
2018-08-05 18:06:39 -04:00
Andrew Kelley
9bd8b01650
fix tagged union initialization with a runtime void
...
closes #1328
2018-08-03 15:21:08 -04:00
kristopher tate
298abbcff8
better support for `_` identifier
...
* disallow variable declaration of `_`
* prevent `_` from shadowing itself
* prevent read access of `_`
closes #1204
closes #1320
2018-08-03 02:57:17 -04:00
Andrew Kelley
895f262a55
pull request fixups
...
* clean up parser code
* fix stage2 parse and render code
* remove redundant test
* make stage1 compile tests leaner
2018-08-02 14:15:31 -04:00
kristopher tate
9b890d7067
test/cases/cancel.zig: update suspend to use @handle();
...
Tracking Issue #1296 ;
2018-08-02 17:47:03 +09:00
kristopher tate
9bed23f8b7
test/cases/coroutines.zig: update suspend to use @handle();
...
Tracking Issue #1296 ;
2018-08-02 17:46:41 +09:00
kristopher tate
51955a5ca2
test/compile_errors.zig: update test to reflect that the promise symbol is no in scope with suspend;
...
Tracking Issue #1296 ;
2018-08-02 17:02:14 +09:00
kristopher tate
9b3cebcdb9
test/cases/coroutines.zig: test for immediate resume inside of suspend with @handle();
...
Tracking Issue #1296 ;
2018-08-02 17:02:14 +09:00
kristopher tate
3241ada468
test/cases/coroutines.zig: update test to reflect that the promise symbol is no in scope with suspend;
...
Tracking Issue #1296 ;
2018-08-02 17:02:14 +09:00
kristopher tate
79792a32e1
test/cases/coroutine_await_struct.zig: update test to reflect that the promise symbol is no in scope with suspend;
...
Tracking Issue #1296 ;
2018-08-02 16:59:11 +09:00
kristopher tate
13ec5db234
test/compile_errors.zig: @handle() in non-async function
...
Tracking Issue #1296 ;
2018-08-02 16:50:08 +09:00
kristopher tate
c546f750f1
test/compile_errors.zig: @handle() called outside of function definition;
...
Tracking Issue #1296 ;
2018-08-02 16:50:08 +09:00
kristopher tate
1f0040dd92
test/cases/coroutines.zig: remove dummy assert used for testing;
2018-08-02 16:50:08 +09:00
kristopher tate
0ee6502562
src/codegen.cpp: remove `add_node_error` from `ir_render_handle`;
...
Tracking Issue #1296 ;
Thanks @andrewrk ;
2018-08-02 16:50:08 +09:00
kristopher tate
9366a58bdd
test/cases/couroutines.zig: test @handle();
...
Tracking Issue #1296 ;
2018-08-02 16:50:08 +09:00
Andrew Kelley
c91c781952
add behavior tests for cancel semantics
2018-07-30 12:49:53 -04:00
Andrew Kelley
442e244b4d
suspend sets suspend bit
2018-07-27 17:16:00 -04:00
Andrew Kelley
2cbad364c1
add compile error for ignoring return value of while loop bodies
...
closes #1049
2018-07-26 18:29:07 -04:00
Andrew Kelley
fd575fe1f3
add compile error for missing parameter name of generic function
2018-07-25 18:15:55 -04:00
Andrew Kelley
84195467ad
add compile error for non-inline for loop on comptime type
2018-07-25 17:08:55 -04:00
Andrew Kelley
02713e8d8a
fix race conditions in self-hosted compiler; add test
...
* fix race condition in std.event.Channel deinit
* add support to zig build for --no-rosegment
* add passing self-hosted compare-output test for calling a function
* put a global lock on LLD linking because it's not thread safe
2018-07-24 21:28:54 -04:00
Andrew Kelley
29e19ace36
fix logic for determining whether param requires comptime
...
closes #778
closes #1213
2018-07-24 10:21:33 -04:00
Andrew Kelley
5a919dd82d
Merge remote-tracking branch 'origin/master' into self-hosted-libc-hello-world
2018-07-23 14:32:13 -04:00
Andrew Kelley
d767fae47e
self-hosted: add first compare-output test
2018-07-23 00:35:53 -04:00
Andrew Kelley
f5a67dba08
self-hosted: implicit cast comptime ints to other ints
...
we now have successful exit codes from main linking
against libc
2018-07-20 01:46:49 -04:00
Andrew Kelley
0a880d5e60
fix generation of error defers for fns inside fns
...
closes #878
2018-07-19 18:06:41 -04:00
Andrew Kelley
bd1c55d2c2
self-hosted: compile errors for return in wrong place
...
* outside fn definition
* inside defer expression
2018-07-18 17:43:36 -04:00
Jimmi Holst Christensen
fd3a41dadc
Allow pointers to anything in extern/exported declarations ( #1258 )
...
* type_allowed_in_extern accepts all ptr not size 0
* Generate correct headers for none extern structs/unions/enums
2018-07-18 11:00:42 -04:00
Jimmi HC
b7be082bd9
-Dskip-release now also skips build example tests
2018-07-18 10:28:14 +02:00
Andrew Kelley
cbfe9a4077
fix @setEvalBranchQuota not respected in generic fn calls
...
closes #1257
2018-07-17 23:37:17 -04:00
Andrew Kelley
0fa24b6b75
allow implicit cast of undefined to optional
2018-07-16 19:26:15 -04:00
Andrew Kelley
e9a03cccf3
all integer sizes are available as primitives
...
* fix wrong implicit cast for `@IntType` bit_count parameter.
* fix incorrect docs for `@IntType` bit_count parameter.
closes #1242
closes #745
closes #1240
2018-07-16 10:53:15 -04:00
Andrew Kelley
f78d4ed30c
add an assertion to the test
2018-07-14 11:33:01 -04:00
Eduardo Sánchez Muñoz
722b9b9e59
codegen: Store returned value if type is 'handle_is_ptr' and function is not 'first_arg_ret'.
...
Seems to fix #1230 , includes test.
2018-07-14 11:33:01 -04:00
Andrew Kelley
5354d1f5fc
allow == for comparing optional pointers
...
closes #658
2018-07-13 12:34:42 -04:00
Andrew Kelley
9751a0ae04
std.atomic: use spinlocks
...
the lock-free data structures all had ABA problems and
std.atomic.Stack had a possibility to load an unmapped memory address.
2018-07-11 19:38:01 -04:00
Andrew Kelley
9bdcd2a495
add std.event.Future
...
This is like a promise, but it's for multiple getters, and
uses an event loop.
2018-07-11 16:00:06 -04:00
Andrew Kelley
5954c94d20
build system: add -Dskip-release option to test faster
2018-07-11 14:09:05 -04:00
Andrew Kelley
3f30897fdc
add compile error for disallowed types in extern structs
...
closes #1218
2018-07-11 14:08:56 -04:00