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
Andrew Kelley
28f9230b40
fix crash when calling comptime-known undefined function ptr
...
closes #880
closes #1212
2018-07-10 10:12:08 -04:00
Andrew Kelley
2ee67b7642
langref: docs for invalid error set cast and incorrect pointer alignment
...
also add detection of incorrect pointer alignment at compile-time
of pointers that were constructed with `@intToPtr`.
2018-07-09 11:13:29 -04:00
Andrew Kelley
9eb51e20ed
fix crash on @ptrToInt of a *void
...
closes #1192
2018-07-09 10:44:06 -04:00
Andrew Kelley
d8295c1889
add @popCount intrinsic
2018-07-07 00:25:32 -04:00
Andrew Kelley
4ad4cd2654
fix iterating over a void slice
...
closes #1203
2018-07-06 17:27:44 -04:00
Andrew Kelley
1cf7511dc9
add compile error notes for where struct definitions are
...
closes #1202
2018-07-06 16:20:46 -04:00
Isaac Hier
9cff23dbf9
Fix assertion crash on enum switch values
2018-07-04 13:27:10 -04:00
Isaac Hier
9395162a7c
Debug enum issue
2018-07-04 12:47:35 -04:00
Andrew Kelley
8c39cdc89f
fix await on early return when return type is struct
...
previously, await on an early return would try to access the
destroyed coroutine frame; now it copies the result into a
temporary variable before destroying the coroutine frame
2018-07-04 11:51:02 -04:00
Andrew Kelley
35463526cc
add runtime safety for `@intToEnum`; add docs for runtime safety
...
See #367
2018-07-02 15:50:28 -04:00
Andrew Kelley
4c0e280d6d
Merge pull request #1185 from ziglang/undefined-at-comptime-improvements
...
Operators now throw a compiler error when operating on undefined values
2018-07-01 01:33:23 -04:00
Jimmi Holst Christensen
b182151de5
Fixed line numbers for tests
2018-06-30 21:59:14 +02:00
Jimmi Holst Christensen
ecd5e60be9
Expanded the list of operators that catch undefined values at comptime
2018-06-30 20:50:09 +02:00
Jimmi Holst Christensen
42033ea3ca
Merge pull request #1167 from ziglang/comptime-array-by-value
...
Implement const_values_equal for arrays
2018-06-30 18:58:31 +02:00
Jimmi Holst Christensen
01bd5c46e1
Revert "ir_resolve_const now checks recursivly for undef values"
...
This reverts commit 4c3f27ce1e
.
2018-06-30 17:35:06 +02:00
isaachier
f1c56f7f22
Clarify reason implicit cast does not work for large RHS ( #1168 )
...
* Clarify reason implicit cast does not work for large RHS
2018-06-29 14:52:25 -04:00
Jimmi HC
4c3f27ce1e
ir_resolve_const now checks recursivly for undef values
2018-06-29 10:21:43 +02:00
Jimmi HC
3ec38b2494
Implement const_values_equal for array type
...
* This allows arrays to be passed by value at comptime
2018-06-28 10:34:37 +02:00
Marc Tiehuis
4a35d7eeeb
Correct hex-float parsing
...
Unblocks #495 .
2018-06-28 20:12:03 +12:00