Andrew Kelley
004c383292
fix translate-c incorrectly translating negative enum init values
...
closes #1360
2018-09-24 12:19:16 -04:00
Andrew Kelley
8a7737eef4
fix godbolt cli test on non-linux-x86_64 hosts
2018-09-24 12:01:51 -04:00
Andrew Kelley
6d048aa3bf
add panic function to godbolt CLI API test
2018-09-24 11:14:39 -04:00
Andrew Kelley
a155f2973b
add test to cover the CLI API that godbolt is using
...
closes #1399
2018-09-24 11:12:21 -04:00
Andrew Kelley
c84548e71d
fix @compileLog having unintended side effects
...
closes #1459
2018-09-22 10:46:22 -04:00
Andrew Kelley
5c15c5fc48
add compile error for slice of undefined slice
...
closes #1293
2018-09-22 10:04:47 -04:00
Andrew Kelley
2e27407161
stage1: unify 2 implementations of pointer deref
...
I found out there were accidentally two code paths
in zig ir for pointer dereference. So this should
fix a few bugs.
closes #1486
2018-09-21 18:47:12 -04:00
Andrew Kelley
9e5cd43e6d
fix comptime string concatenation ignoring slice bounds
...
closes #1362
2018-09-21 15:45:13 -04:00
Andrew Kelley
7c5e3e1f8e
fixups
2018-09-21 14:15:58 -04:00
Andrew Kelley
5a21d3dce0
Merge branch 'BitByteOffsetOfs' of https://github.com/raulgrell/zig into raulgrell-BitByteOffsetOfs
2018-09-21 13:10:21 -04:00
Andrew Kelley
44f2ee101f
fix comptime slice of pointer to array
...
closes #1565
2018-09-21 10:31:11 -04:00
Andrew Kelley
9c8dfadbb1
add compile error for casting const array to mutable slice
...
See #1565
2018-09-20 12:24:51 -04:00
Andrew Kelley
f8fe517d12
better string literal caching implementation
...
We were caching the ConstExprValue of string literals,
which works if you can never modify ConstExprValues.
This premise is broken with `comptime var ...`.
So I implemented an optimization in ConstExprValue
arrays, where it stores a `Buf *` directly rather
than an array of ConstExprValues for the elements,
and then similar to array of undefined, it is
expanded into the canonical form when necessary.
However many operations can happen directly on the
`Buf *`, which is faster.
Furthermore, before a ConstExprValue array is expanded
into canonical form, it removes itself from the string
literal cache. This fixes the issue, because before an
array element is modified it would have to be expanded.
closes #1076
2018-09-20 11:04:31 -04:00
Andrew Kelley
345f8db1c4
fix optional pointer to empty struct incorrectly being non-null
...
closes #1178
2018-09-18 17:51:50 -04:00
Andrew Kelley
c1af360532
add compile error for slice.*.len
...
closes #1372
2018-09-18 16:32:40 -04:00
Andrew Kelley
8c77c5705f
implementation for bitcasting extern enum type to c_int
...
closes #1036
2018-09-18 15:00:14 -04:00
Andrew Kelley
5fd3af9dc6
fix implicit cast of packed struct field to const ptr
...
closes #966
2018-09-18 14:34:30 -04:00
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
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
Andrew Kelley
2fa588e81d
fix coroutine accessing freed memory
...
closes #1164
2018-06-27 18:45:21 -04:00
Andrew Kelley
19961c50e4
fix comptime @tagName crashing sometimes
...
closes #1118
2018-06-27 13:15:55 -04:00
Ben Noordhuis
440c1d52b4
simplify comptime floating-point @divTrunc
...
Replace a conditional ceil/floor call with an unconditional trunc call.
2018-06-27 16:20:04 +02:00
Ben Noordhuis
fd75e73ee9
add f16 type
...
Add support for half-precision floating point operations.
Introduce `__extendhfsf2` and `__truncsfhf2` in std/special/compiler_rt.
Add `__gnu_h2f_ieee` and `__gnu_f2h_ieee` as aliases that are used in
Windows builds.
The logic in std/special/compiler_rt/extendXfYf2.zig has been reworked
and can now operate on 16 bits floating point types.
`extendXfYf2()` and `truncXfYf2()` are marked `inline` to work around
a not entirely understood stack alignment issue on Windows when calling
the f16 versions of the builtins.
closes #1122
2018-06-27 16:20:04 +02:00
Ben Noordhuis
0ebc7b66e6
scope variables in floating point cast tests
...
Fixes a bug where the result of a @floatCast wasn't actually checked; it
was checking the result from the previous @floatCast.
2018-06-27 16:20:04 +02:00
Andrew Kelley
11ca38a4e9
fix crash for optional pointer to empty struct
...
closes #1153
2018-06-26 15:27:41 -04:00
Andrew Kelley
8866bef92c
clean up self hosted main. delete unsupported commands
2018-06-22 01:54:38 -04:00
Andrew Kelley
459d72f873
fix compiler crash for invalid enum
...
closes #1079
closes #1147
2018-06-21 17:41:49 -04:00
Andrew Kelley
5f38d6e2e9
add casting docs, __extenddftf2, and __extendsftf2
2018-06-21 14:44:35 -04:00
Isaac Hier
f1207a8e74
Add test case
2018-06-21 08:32:05 -04:00
Ben Noordhuis
eb6a8e6a3b
fix f128 remainder division bug
...
The modulo operation computed rem(b+rem(a,b), b) which produces -1
for a=1 and b=2.
Switch to a - b * trunc(a/b) which produces the expected result, 1.
closes #1137
2018-06-20 17:37:38 -04:00
Andrew Kelley
e891f9cd9d
zig fmt
2018-06-20 17:16:27 -04:00
kristopher tate
71db8df548
std: update stdlib to match updated allocator create signature; ref #733
2018-06-21 00:40:21 +09:00
Andrew Kelley
55193cb13b
fix runtime fn ptr equality codegen
...
closes #1140
2018-06-20 06:46:53 -04:00
Andrew Kelley
7c99c30bf4
fix calling method with comptime pass-by-non-copyign-value self arg
...
closes #1124
2018-06-19 19:35:59 -04:00
Andrew Kelley
42db807f37
remove redundant implicit casting code
...
and introduce better type mismatch errors
closes #1061
2018-06-19 18:51:46 -04:00
Andrew Kelley
c7804277bf
`@floatToInt` now has safety-checked undefined behavior
...
when the integer part does not fit in the destination integer type
* Also fix incorrect safety triggered for integer casting an
`i32` to a `u7`. closes #1138
* adds compiler-rt function: `__floatuntidf`
2018-06-19 16:06:10 -04:00
Andrew Kelley
85422d7aea
Merge pull request #1136 from alexnask/typeinfo_improvements
...
@typeInfo now uses optional types instead of @typeOf(undefined)
2018-06-19 11:46:32 -04:00
Alexandros Naskos
1392313236
@typeInfo now uses optional types instead of @typeOf(undefined)
2018-06-19 17:45:19 +03:00
Andrew Kelley
a3ddd0826b
remove enum to/from int casting syntax; add `@enumToInt`/`@intToEnum`
...
see #1061
2018-06-19 03:50:38 -04:00
Andrew Kelley
626b73e8be
remove error to/from int casting syntax; add `@errorToInt`/`@intToError`
...
See #1061
2018-06-18 18:48:29 -04:00
Andrew Kelley
1aafbae5be
remove []u8 casting syntax. add `@bytesToSlice` and `@sliceToBytes`
...
See #1061
2018-06-18 17:25:29 -04:00
Andrew Kelley
5d705fc6e3
remove error set casting syntax. add `@errSetCast`
...
See #1061
2018-06-18 15:01:42 -04:00
Andrew Kelley
8fd7cc11e1
disallow opaque as a return type of fn type syntax
...
closes #1115
2018-06-18 11:12:15 -04:00
Andrew Kelley
d49d6f0cde
fix compiler crash when using @intToFloat with float literal
...
closes #1132
2018-06-18 11:04:18 -04:00
Andrew Kelley
4210f1f6a0
remove bool to int syntax. add @boolToInt
...
add missing docs
See #1061
2018-06-18 03:07:16 -04:00
Andrew Kelley
d52ef95f77
disable failing macos test. see #1126
...
I'm unable to reproduce the failure on my mac laptop
more investigation required
2018-06-18 01:09:51 -04:00
Andrew Kelley
74ccf56a4b
update more tests
2018-06-17 12:33:24 -04:00
Andrew Kelley
3c12ba7180
update test cases
2018-06-17 04:32:57 -04:00
Andrew Kelley
7912061226
remove integer and float casting syntax
...
* add `@intCast`
* add `@floatCast`
* add `@floatToInt`
* add `@intToFloat`
See #1061
2018-06-17 02:57:07 -04:00
Andrew Kelley
472b7ef7e6
disable byval
2018-06-16 19:37:00 -04:00
Andrew Kelley
e311cd562b
don't automatically take pointer when passing by non-copying value
...
this commit does not have all tests passing
2018-06-16 19:37:00 -04:00
Andrew Kelley
59b3dc8907
allow passing by non-copying value
...
closes #733
2018-06-16 19:36:33 -04:00
Andrew Kelley
a7d59086b4
disable load dynamic library test
...
it's failing on CI. I will troubleshoot it and then re-enable
2018-06-16 19:36:06 -04:00
Andrew Kelley
c529b814ee
load_dynamic_library test: no need to link libc
2018-06-16 18:54:41 -04:00
Andrew Kelley
48de57d824
add basic std lib code for loading dynamic libraries
...
this is going to only work for very basic libraries;
I plan to slowly add more features over time to support more
complicated libraries
2018-06-16 17:01:23 -04:00
Alexandros Naskos
4ec09ac243
Enabled optional types of zero bit types with no LLVM DI type. ( #1110 )
...
* Zero bit optional types do not need a LLVM DI type
2018-06-14 10:57:28 -04:00
Andrew Kelley
8dd24796c4
disallow implicit casts that break rules for optionals
...
closes #1102
2018-06-13 11:04:09 -04:00
Andrew Kelley
86adc1ef39
add docs and missing test case for merging error sets
...
See #367
2018-06-12 19:38:59 -04:00
Andrew Kelley
259413251d
fix ability to call mutating methods on zero size structs
...
closes #838
2018-06-12 15:06:02 -04:00
Andrew Kelley
03c16c6c54
implement @tagName as a switch instead of table lookup
...
closes #976
closes #1080
2018-06-11 14:58:42 -04:00
Andrew Kelley
77678b2cbc
breaking syntax change: orelse keyword instead of ?? ( #1096 )
...
use the `zig-fmt-optional-default` branch to have zig fmt
automatically do the changes.
closes #1023
2018-06-10 01:13:51 -04:00
Andrew Kelley
ec1b6f6673
breaking syntax change: ??x to x.? ( #1095 )
...
See #1023
This also renames Nullable/Maybe to Optional
2018-06-09 23:42:14 -04:00
Andrew Kelley
6edd81109d
nullable pointers follow const-casting rules
...
any *T -> ?*T cast is allowed implicitly, even
when it occurs deep inside the type, and the cast
is a no-op at runtime.
in order to add this I had to make the comptime value
representation of nullable pointers the same as the
comptime value representation of normal pointers,
so that we don't have to do any recursive transformation
of values when doing this kind of cast.
2018-06-09 00:26:26 -04:00
Jimmi HC
bf3d1c1aab
Allow access of array.len through a pointer
2018-06-08 09:21:31 +02:00
Andrew Kelley
f0b6dac1f2
add implicit casts from `*[N]T`
...
* to `[]T`
* to `[*]T`
See #770
2018-06-07 22:41:58 -04:00
Andrew Kelley
b65203f573
remove @canImplicitCast builtin
...
nobody will miss it
2018-06-07 19:50:25 -04:00
Andrew Kelley
31aefa6a21
fix structs that contain types which require comptime
...
Now, if a struct has any fields which require comptime,
such as `type`, then the struct is marked as requiring
comptime as well. Same goes for unions.
This means that a function will implicitly be called
at comptime if the return type is a struct which contains
a field of type `type`.
closes #586
2018-06-07 18:07:30 -04:00
Andrew Kelley
d3693dca73
Pointer Reform: update @typeInfo
...
* add assertion for trying to do @typeInfo on global error set
* remove TypeInfo.Slice
* add TypeInfo.Pointer.Size with possible values
- One
- Many
- Slice
See #770
2018-06-06 00:39:39 -04:00
Andrew Kelley
76c8efd56c
add test for not allowing implicit cast from T to [*]const T
...
See #770
2018-06-05 23:54:14 -04:00
Andrew Kelley
bd13e757e7
disable deref syntax for unknown length pointers
...
See #770
2018-06-05 23:26:43 -04:00
Andrew Kelley
0ccc186869
disable field access for unknown length pointers
...
See #770
2018-06-05 23:26:43 -04:00
Andrew Kelley
652f4bdf62
disallow unknown-length pointer to opaque
...
This also means that translate-c has to detect when a pointer to
opaque is happening, and use `*` instead of `[*]`.
See #1059
2018-06-05 18:03:21 -04:00
Andrew Kelley
7a09482536
fix crash when evaluating return type has compile error
...
closes #1058
2018-06-05 10:48:53 -04:00
Jimmi HC
a8146ade2a
Renamed UndefinedLiteral to Undefined
2018-06-05 11:54:11 +02:00
Jimmi HC
236c680f6b
Removed NullLiteral to Null
2018-06-05 11:30:01 +02:00
Jimmi HC
02cb220faf
Renamed "(int/float literal)" to "comptime_int/float"
2018-06-05 11:14:43 +02:00
Andrew Kelley
e53b683bd3
Pointer Reform: proper slicing and indexing ( #1053 )
...
* enable slicing for single-item ptr to arrays
* disable slicing for other single-item pointers
* enable indexing for single-item ptr to arrays
* disable indexing for other single-item pointers
see #770
closes #386
2018-06-04 22:11:14 -04:00
Andrew Kelley
d21a1922eb
support `zig fmt: off` and `zig fmt: on` between top level decls
...
closes #1030
closes #1033
2018-06-04 12:15:02 -04:00
Andrew Kelley
96164ce613
disallow single-item pointer indexing
...
add pointer arithmetic for unknown length pointer
2018-06-04 01:39:57 -04:00
Andrew Kelley
b85b68a7fd
better compile error for error sets behind nullable
2018-06-02 15:20:51 -04:00
Andrew Kelley
5f38a01ede
run zig fmt
2018-06-01 01:22:35 -04:00
Andrew Kelley
2a7c8c5b10
add test case for pointer to type and slice of type
...
closes #588
2018-06-01 00:18:10 -04:00
Andrew Kelley
019217d7a2
fix regressions
2018-06-01 00:17:31 -04:00
Andrew Kelley
fcbb7426fa
use * for pointer type instead of &
...
See #770
To help automatically translate code, see the
zig-fmt-pointer-reform-2 branch.
This will convert all & into *. Due to the syntax
ambiguity (which is why we are making this change),
even address-of & will turn into *, so you'll have
to manually fix thes instances. You will be guaranteed
to get compile errors for them - expected 'type', found 'foo'
2018-05-31 17:28:07 -04:00
Andrew Kelley
ea58f4a5a9
run zig fmt on the codebase
2018-05-30 16:09:11 -04:00
Jimmi HC
2b3af4ef6b
fixed #1009
...
ir_make_type_info_defs already calls resolve_top_level_decl on all Tld
when building the def array. This means, that there is no reason that
analyze_fn_body is nessesary, as the fn type should have already been
resolved completly. The only thing analyze_fn_body does here, is cause
problems with generic functions.
2018-05-30 10:30:09 +02:00
Andrew Kelley
0c16cd2d0e
run zig fmt on the codebase
...
See #1003
2018-05-29 04:23:38 -04:00
Andrew Kelley
c029f4bfc4
trailing comma after var args is not supported
2018-05-25 20:41:14 -04:00
Andrew Kelley
08f95d0c2f
enum fields with a type are not supported
...
the c++ codebase lets it slide
the self hosted parser correctly reports a parse error
2018-05-25 01:10:54 -04:00
Andrew Kelley
ca49b6f6b4
struct fields with no explicit type are not supported
...
the c++ codebase lets it slide
the self hosted parser correctly reports a parse error
2018-05-25 00:39:18 -04:00
Andrew Kelley
43085417be
update github.com/zig-lang to github.com/ziglang
2018-05-24 21:27:44 -04:00
Andrew Kelley
c38b165db4
all tests passing with postfix deref syntax
2018-05-17 23:21:44 -04:00
Andrew Kelley
5cfabdd493
Merge remote-tracking branch 'origin/master' into pointer-reform
2018-05-16 00:02:26 -04:00
Andrew Kelley
74b10c08d1
fix @typeInfo not setting a field to comptime
2018-05-15 14:11:41 -04:00
Andrew Kelley
86a352c45b
Merge branch 'master' into pointer-reform
2018-05-13 13:38:03 -04:00
Andrew Kelley
a6ae45145f
add @newStackCall builtin function
...
See #1006
2018-05-12 17:35:15 -04:00
Andrew Kelley
277b9cf878
fix comptime code modification of global const
...
closes #1008
2018-05-11 22:41:44 -04:00
Marc Tiehuis
efa39c5343
Fix bigint shift-right partial shift
2018-05-10 22:26:26 +12:00
Andrew Kelley
6928badd85
Merge branch 'master' into pointer-reform
2018-05-09 23:43:07 -04:00
Andrew Kelley
bf21747a42
translate-c: fix typedef duplicate definition of variable
...
closes #998
2018-05-09 20:23:36 -04:00
Jimmi HC
9b29c872ce
Added Slice as it's own type info in userland
2018-05-09 09:34:04 +02:00
Andrew Kelley
77a1a216d2
tagged union field access prioritizes members over enum tags
...
closes #959
2018-05-07 16:43:20 -04:00
Marc Tiehuis
d7b029995c
Fix bigint multi-limb shift and masks
2018-05-05 22:40:29 +12:00
Andrew Kelley
b9e320dd52
Merge pull request #951 from alexnask/reflect_reify
...
Metaprogramming - @typeInfo [DONE]
2018-05-03 23:02:33 -04:00
Jimmi Holst Christensen
aa2586de18
Fixed extern enums having the wrong size ( #970 )
...
Fixed extern enums having the wrong size
See #977
2018-05-03 22:27:04 -04:00
Andrew Kelley
adbb691f46
fix behavior tests for ReleaseSmall
2018-05-02 22:48:04 -04:00
Andrew Kelley
6fd14f23b5
add ReleaseSmall mode in zig tests
...
closes #969
2018-05-02 22:41:02 -04:00
Alexandros Naskos
131c133bb7
Fixed inlining determination test ( #972 )
...
When deciding wether we should inline a scope, look up the parents until we get to a function definition scope
2018-05-02 21:43:07 -04:00
Jimmi Holst Christensen
1a9403f38a
Added better support for none pure enums in tranlate C
2018-05-02 21:50:41 +02:00
Alexandros Naskos
7d239414f7
Fixed type info test, added documentation.
2018-05-01 13:42:20 +03:00
Alexandros Naskos
1b6e97355d
Added type info tests to behavior test listing
2018-05-01 13:31:14 +03:00
Alexandros Naskos
255c0ef406
Resolved merge conflict.
2018-05-01 13:09:34 +03:00
Alexandros Naskos
e1535ee0a9
Added typeInfo tests
2018-05-01 13:01:54 +03:00
Alexandros Naskos
ff1c4e1f13
Added tests.
2018-05-01 13:00:39 +03:00
Andrew Kelley
ac4d55dec1
behavior tests passing with new pointer deref syntax
2018-05-01 01:53:04 -04:00
Andrew Kelley
a35b366eb6
[breaking] delete ptr deref prefix op
...
start using zig-fmt-pointer-reform branch build of zig fmt
to fix code to use the new syntax
all of test/cases/* are processed, but there are more left
to be done - all the std lib used by the behavior tests
2018-04-30 20:35:54 -04:00
Andrew Kelley
76ab1d2b6c
support foo.* for ptr deref
...
See #770
2018-04-30 14:20:56 -04:00
Andrew Kelley
0bb054e5e7
Merge pull request #930 from zig-lang/float-printing
...
Finish and fix float printing
2018-04-28 22:43:52 -04:00
Andrew Kelley
ec2a81a081
fix compiler-rt ABI for x86_64 windows
2018-04-28 22:03:07 -04:00
Jimmi Holst Christensen
fba0347ec4
.ReturnType and @ArgType now emits errors on unresolved types
...
related: #846
2018-04-28 17:17:48 +02:00
Jimmi Holst Christensen
2fc34eaa58
Functions with infered error set can now return literals
...
fixes #852
2018-04-28 16:27:31 +02:00
Jimmi Holst Christensen
3178528335
Removed zero sized error set optimization
...
fixes #762
fixes #818
2018-04-28 14:05:08 +02:00
Andrew Kelley
15bf0c1541
fix interaction between defer and labeled break
...
closes #830
2018-04-23 18:06:33 -04:00
Andrew Kelley
89a4c373d3
fix bigint twos complement implementation
...
closes #948
2018-04-23 12:06:18 -04:00
Andrew Kelley
8503eff8c1
add compile error for invalid deref on switch target
...
closes #945
2018-04-22 23:46:55 -04:00
Andrew Kelley
21767144fc
linux: support VDSO for clock_gettime
...
also fix a compiler crash when using cmpxchg with nullable pointer
2018-04-22 18:11:50 -04:00
Andrew Kelley
c4840d78fb
add test case for #936
2018-04-21 02:10:22 -04:00
Jimmi Holst Christensen
1b91478bff
Optimized field ptr ir for hot path and fix assignment bug
2018-04-19 21:34:18 +02:00
Jimmi Holst Christensen
6b4f6ebd89
Added field builtin function
2018-04-19 20:11:16 +02:00
Andrew Kelley
06909ceaab
support break in suspend blocks
...
* you can label suspend blocks
* labeled break supports suspend blocks
See #803
2018-04-18 22:21:54 -04:00
Andrew Kelley
f1f998e071
improve cmpxchg
...
* remove @cmpxchg, add @cmpxchgWeak and @cmpxchgStrong
- See explanations in the langref.
* add operand type as first parameter
* return type is ?T where T is the operand type
closes #461
2018-04-18 12:16:42 -04:00
Alexandros Naskos
6492763bef
Fixed test build code
2018-04-16 04:06:00 +03:00
Andrew Kelley
b9360640ce
add @atomicLoad builtin
...
See #174
2018-04-15 18:12:00 -04:00