Andrew Kelley
5c3a9a1a3e
improvements to `@asyncCall`
...
* `await @asyncCall` generates better code. See #3065
* `@asyncCall` works with a real `@Frame(func)` in addition to
a byte slice. Closes #3072
* `@asyncCall` allows passing `{}` (a void value) as the result
pointer, which uses the result location inside the frame.
Closes #3068
* support `await @asyncCall` on a non-async function. This is in
preparation for safe recursion (#1006 ).
2019-08-31 18:50:16 -04:00
Andrew Kelley
6ab8b2aab4
support recursive async and non-async functions
...
which heap allocate their own frames
related: #1006
2019-08-30 20:06:02 -04:00
Andrew Kelley
e9a4bcbcc6
fix regressions
2019-08-29 22:44:07 -04:00
Andrew Kelley
428a2fdedd
better handle struct depends on itself via optional field
...
closes #1995
2019-08-27 13:59:18 -04:00
Andrew Kelley
d9ed55f017
fix not properly casting align values
...
and add check for alignment specified on enum fields
2019-08-27 12:54:50 -04:00
Andrew Kelley
db50cf7049
fix more compile error regressions
2019-08-26 22:38:45 -04:00
Andrew Kelley
bad4b040cc
miscellaneous fixes regarding compile errors
2019-08-26 18:35:36 -04:00
Andrew Kelley
d316f70450
fix regression on struct field with undefined type
2019-08-26 14:01:59 -04:00
Andrew Kelley
73a7747a9c
fix some compile error regressions
2019-08-26 12:43:36 -04:00
Andrew Kelley
276eb4402b
specify the target for the newest test case
2019-08-20 14:40:57 -04:00
Timon Kruiper
2addec8ea1
compiler error when variable in asm template cannot be found
2019-08-20 14:11:03 -04:00
Andrew Kelley
ea1734773b
add compile error for async frames depending on themselves
2019-08-17 19:47:49 -04:00
Andrew Kelley
66a490c27c
detect non-async function pointer of inferred async function
...
closes #3075
2019-08-17 16:49:23 -04:00
Vexu
0ff396c34f
add compile error for incorrect atomic ordering in fence #3082
2019-08-17 16:05:41 -04:00
Andrew Kelley
4d8a6f6fea
fix compiler not checking alignment of function frames
...
closes #3086
2019-08-17 13:04:50 -04:00
Andrew Kelley
bf7b6fbbdb
add missing compile error for fn call bad implicit cast
...
when the function's return type handle is a pointer but the result
location's result value type handle is not a pointer
closes #3055
2019-08-16 16:30:24 -04:00
Andrew Kelley
13c584d325
add compile error for casting const frame to anyframe
...
See #3063
2019-08-16 11:38:41 -04:00
Andrew Kelley
7798054b58
add tests for bad implicit casting of anyframe types
...
See #3063
2019-08-16 11:00:21 -04:00
Andrew Kelley
5df89dafef
add test for wrong frame type used for async call
...
See #3063
2019-08-16 10:49:00 -04:00
Andrew Kelley
1254a453b9
add compile error for @Frame() of generic function
...
See #3063
2019-08-16 10:44:51 -04:00
Andrew Kelley
55f5cee86b
fix error return traces for async calls of blocking functions
2019-08-15 15:06:05 -04:00
Andrew Kelley
13b5a4bf8c
remove `cancel`
2019-08-15 14:05:12 -04:00
Andrew Kelley
f3f838cc01
add compile error for await in exported function
2019-08-14 11:22:12 -04:00
Andrew Kelley
8a9289996a
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
2019-08-13 11:39:32 -04:00
Andrew Kelley
4d8d513e16
all tests passing
2019-08-11 19:53:10 -04:00
Andrew Kelley
1b83ee78a4
allow comptime_int to implicit cast to comptime_float
2019-08-11 12:01:02 -04:00
Andrew Kelley
bfa1d12fba
better compile errors when frame depends on itself
2019-08-08 13:44:57 -04:00
Andrew Kelley
87710a1cc2
implement `@asyncCall` which supports async function pointers
2019-08-03 16:17:42 -04:00
Andrew Kelley
c879209661
add compile error for calling async function pointer
2019-08-03 02:40:38 -04:00
Andrew Kelley
24d78177ee
add compile error for async call of function pointer
2019-08-03 01:06:14 -04:00
Andrew Kelley
b3b6a98451
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
2019-08-02 16:31:43 -04:00
Andrew Kelley
d105769926
fix regressions regarding writing through const pointers
2019-08-02 16:09:40 -04:00
Andrew Kelley
19ee495750
add error for function with ccc indirectly calling async function
2019-07-23 19:35:41 -04:00
Andrew Kelley
af8661405b
fix usingnamespace
...
It used to be that usingnamespace was only allowed at top level. This
made it OK to put the state inside the AST node data structure. However,
now usingnamespace can occur inside any aggregate data structure, and
therefore the state must be in the TopLevelDeclaration rather than in
the AST node.
There were two other problems with the usingnamespace implementation:
* It was passing the wrong destination ScopeDecl, so it could cause an
incorrect error such as "import of file outside package path".
* When doing `usingnamespace` on a file that already had
`pub usingnamespace` in it would "steal" the usingnamespace, causing
incorrect "use of undeclared identifier" errors in the target file.
closes #2632
closes #2580
2019-07-19 16:56:44 -04:00
Andrew Kelley
741c74e427
cleanups
2019-07-16 11:50:00 -04:00
Andrew Kelley
45cc488cef
Merge branch 'main-return-!u8' of https://github.com/SamTebbs33/zig into SamTebbs33-main-return
2019-07-16 11:27:11 -04:00
hryx
6bfa8546bb
Unicode escapes: stage1 tokenizer and behavior tests
2019-07-04 22:40:19 -07:00
SamTebbs33
f24b8f2a4a
Support returning !u8 from main
2019-07-04 14:26:05 +01:00
Andrew Kelley
96fd103073
improve the error message and test coverage
2019-07-04 00:35:28 -04:00
Andrew Kelley
bfe0bf695b
Merge branch 'impl-1107' of https://github.com/emekoi/zig into emekoi-impl-1107
2019-07-03 23:40:47 -04:00
emekoi
a1b952f4b0
added tests for #1107 and a note in the reference
2019-07-03 13:12:14 -05:00
Andrew Kelley
9daf0140e5
add missing compile error for comptime continue inside runtime catch
...
See #2604
2019-07-02 21:14:42 -04:00
Andrew Kelley
df11512f85
fixups
2019-07-02 16:52:55 -04:00
Andrew Kelley
1ccf6a2c9e
compile error for using slice as array init expr type
...
when there are more than 0 elements.
closes #2764
2019-06-27 12:24:13 -04:00
Andrew Kelley
fd4c5f54f0
all compile error tests passing
2019-06-25 19:03:56 -04:00
Andrew Kelley
0a77325916
fix several compile error test regressions
2019-06-25 18:06:03 -04:00
Andrew Kelley
42ea2d0d1c
fix `@export` for arrays and allow sections on extern variables
...
previously `@export` for an array would panic with a TODO message.
now it will do the export. However, it uses the variable's name
rather than the name passed to `@export`. Issue #2679 remains open
for that problem.
2019-06-14 15:28:52 -04:00
SamTebbs33
6c160b8856
Add check for null body in if, for and while
2019-06-10 00:41:33 -04:00
Andrew Kelley
b735764898
different array literal syntax when inferring the size
...
old syntax: []i32{1, 2, 3}
new syntax: [_]i32{1, 2, 3}
closes #1797
2019-06-09 19:26:32 -04:00
Andrew Kelley
78f32259da
default struct field initialization expressions
...
closes #485
2019-05-30 15:46:11 -04:00
Andrew Kelley
1ccbd1fb67
`use` works on unions and enums in addition to structs
2019-05-29 16:31:49 -04:00
Andrew Kelley
b66438eb80
no "use of undeclared identifer" in dead comptime branches
2019-05-28 18:19:27 -04:00
LemonBoy
528c151a55
Reject undefined as type
...
Make analyze_type_expr behave like ir_resolve_type when the user tries
to use `undefined` as a type.
Closes #2436
2019-05-28 18:02:57 -04:00
Andrew Kelley
269a53b6af
introduce @hasDecl builtin function
...
closes #1439
2019-05-26 16:21:03 -04:00
Shawn Landden
1fdb24827f
breaking changes to all bit manipulation intrinsics
...
* `@clz`, `@ctz`, `@popCount`, `@bswap`, `@bitreverse` now
have a type parameter
* rename @bitreverse to @bitReverse
* rename @bswap to @byteSwap
Closes #2119
Closes #2120
2019-05-16 16:37:58 -04:00
Andrew Kelley
057a5d4898
slice types no longer have field access
...
* fix crash when doing field access of slice types. closes #2486
* remove the deprecated Child property from slice types
* add -Dskip-non-native build option to build script
2019-05-14 21:21:59 -04:00
LemonBoy
b05e8d46ec
Change the enum value allocation strategy
2019-05-11 21:29:53 +02:00
LemonBoy
c766f3f9ca
Support signed types as enum tags
2019-05-11 21:28:58 +02:00
Andrew Kelley
2933d6b848
add test case for previous commit
...
closes #2467
2019-05-10 16:57:37 -04:00
Michael Dusan
d065f297ab
stage1: compile error for loop expr val ignored
...
closes #2460
2019-05-10 10:05:40 -04:00
Jimmi HC
6b10f03b4a
Fixes and simplifications for stage 1 parser
2019-05-10 16:09:58 +02:00
Andrew Kelley
c459edac18
compile error for attempt to cast enum literal to error
...
closes #2203
2019-05-09 13:18:13 -04:00
Andrew Kelley
50bbb34594
C pointers support `null`
...
See #1967
2019-05-08 16:06:34 -04:00
Andrew Kelley
fb2acaff06
`@sizeOf` returns 0 for comptime types
...
This defines `@sizeOf` to be the runtime size of a type, which means
that it is zero for types such as comptime_int, type, and (enum
literal).
See #2209
2019-04-24 22:31:53 -04:00
kristopher tate
fae0c35195
test/compile_errors.zig: add regression test for ziglang/zig#532 ;
2019-04-07 10:37:43 +09:00
emekoi
4a64f26627
added error for implicit cast from *const T to *[1]T. credit: @kristate
2019-03-31 16:47:34 -05:00
Shawn Landden
66f13ba807
stage1: better error message when comparing against null
...
Closes : #2104
2019-03-28 15:54:44 -04:00
Andrew Kelley
5eaead6a56
implement allowzero pointer attribute
...
closes #1953
only needed for freestanding targets.
also adds safety for `@intToPtr` when the address is zero.
2019-03-25 12:55:45 -04:00
Andrew Kelley
3306e43984
add compile error test for invalid enum literal implicit cast
...
See #683
2019-03-24 18:51:24 -04:00
Andrew Kelley
aff7b38838
make switch expressions allow enum literal types
...
See #683
2019-03-24 01:15:21 -04:00
Andrew Kelley
64dddd7afe
add compile error for ignoring error
...
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley
4615ed5ea0
float literals now parse using musl's 128 bit float code
...
fixes float literals not having 128 bit precision
2019-03-22 14:56:03 -04:00
Marc Tiehuis
a3f42a5fe1
Fix compile-error test case for large integer type
2019-03-23 00:20:03 +13:00
Andrew Kelley
15c316b0d8
add docs for assembly and fix global assembly parsing
...
Previously, global assembly was parsed expecting it to have
the template syntax. However global assembly has no inputs,
outputs, or clobbers, and thus does not have template syntax.
This is now fixed.
This commit also adds a compile error for using volatile
on global assembly, since it is meaningless.
closes #1515
2019-03-20 19:00:23 -04:00
Andrew Kelley
6d6195424d
add regression test for invalid multiple dereferences
...
closes #1042
2019-03-16 00:23:18 -04:00
Andrew Kelley
c40448eb9a
add compile error for wrong type with `use`
...
closes #1557
2019-03-16 00:18:10 -04:00
Andrew Kelley
4a5cd0b895
fix while continue block not checking for ignored expression
...
closes #957
2019-03-15 23:52:11 -04:00
Andrew Kelley
67b4de33d2
compile error for import outside package path
...
closes #2024
there's a new cli option `--main-pkg-path` which you can use to choose
a different root package directory besides the one inferred from the
root source file
and a corresponding build.zig API:
foo.setMainPkgPath(path)
2019-03-02 10:38:27 -05:00
Andrew Kelley
5f7d9c5845
@typeInfo for structs and opaque types is the bare name
2019-03-01 17:15:58 -05:00
Andrew Kelley
582fdc2869
fix dependency loops, pub, tests, use decls, root source
...
* fix dependency loop detection
- closes #679
- closes #1500
* fix `pub`
* fix tests
* fix use decls
* main package file gets a special "" namespace path
2019-03-01 15:35:29 -05:00
Andrew Kelley
5424b4320d
remove namespace type; files are empty structs
...
closes #1047
2019-02-28 10:11:32 -05:00
Andrew Kelley
763357c9c3
add test coverage for type used as switch case
...
closes #996
2019-02-26 19:41:36 -05:00
Andrew Kelley
d5fc826437
add test coverage for binary OR on error sets
...
closes #1074
2019-02-26 19:34:22 -05:00
Andrew Kelley
82fafca375
fix the libc compile error tests to only run on linux
2019-02-25 21:46:32 -05:00
Andrew Kelley
152db27146
better error message when forgetting to link against libc
...
closes #1698
2019-02-25 20:09:18 -05:00
Andrew Kelley
3ca861c7dd
add a compile error note when C import fails and not linking libc
...
closes #558
2019-02-25 19:31:30 -05:00
Andrew Kelley
52bb71867d
implement vector negation
...
also fix vector behavior tests, they weren't actually testing
runtime vectors, but now they are.
See #903
2019-02-22 13:28:57 -05:00
Andrew Kelley
1066004b79
better handling of arrays in packed structs
...
* Separate LoadPtr IR instructions into pass1 and pass2 variants.
* Define `type_size_bits` for extern structs to be the same as
their `@sizeOf(T) * 8` and allow them in packed structs.
* More helpful error messages when trying to use types in
packed structs that are not allowed.
* Support arrays in packed structs even when they are not
byte-aligned.
* Add compile error for using arrays in packed structs when the
padding bits would be problematic. This is necessary since
we do not have packed arrays.
closes #677
2019-02-21 14:44:14 -05:00
Andrew Kelley
3ee9d06cbd
packed structs support comptime bitcasting
...
* `type_size_store` is no longer a thing. loading and storing a pointer
to a value may dereference up to `@sizeOf(T)` bytes, even for
integers such as `u24`.
* fix `types_have_same_zig_comptime_repr` to not think that the
same `ZigTypeId` means the `ConstExprValue` neccesarily has the
same representation.
* implement `buf_write_value_bytes` and `buf_read_value_bytes` for
`ContainerLayoutPacked`
closes #1120
2019-02-20 22:40:41 -05:00
Andrew Kelley
079728752e
deduplicate compile errors for undeclared identifiers
...
closes #111
2019-02-20 08:04:46 -05:00
Andrew Kelley
1034af40f9
Merge branch 'slice-deref-failure' of https://github.com/matthew-mcallister/zig into matthew-mcallister-slice-deref-failure
2019-02-19 15:27:10 -05:00
LemonBoy
400006bbe7
Prevent crash in tagged enums rendering ( #1986 )
...
* Prevent crash in tagged enums rendering
* Add a test case
2019-02-19 15:18:57 -05:00
Andrew Kelley
ea3d9d5c53
add test for 74bdc1d1f8
2019-02-18 18:11:30 -05:00
Matthew McAllister
c70ee9177e
Check for duped error messages in compile tests
2019-02-17 15:33:28 -08:00
Matthew McAllister
51783510b9
Deduplicate compile log statement warnings
2019-02-17 14:02:37 -08:00
Matthew McAllister
91989e70ba
Fix lvalue dereference type checking
...
Previously, if a dereference instruction was an lvalue, it would fail to
typecheck that the value being dereferenced was indeed a pointer.
Although a little clunky, this change obviates the need for redundant
type checks scattered about the analysis.
2019-02-16 17:37:47 -08:00
Andrew Kelley
a05e224150
typecheck the panic function
...
this adds the prototype of panic to @import("builtin")
and then uses it to do an implicit cast of the panic
function to this prototype, rather than redoing all the
implicit cast logic.
closes #1894
closes #1895
2019-02-15 19:19:28 -05:00
Andrew Kelley
567c9b688e
Merge pull request #1965 from ziglang/c-pointer-type
...
implement C pointers
2019-02-15 02:20:42 -05:00
Andrew Kelley
d6e0d82c32
translate-c: back to *c_void for opaque types
...
See #1059
2019-02-14 23:09:31 -05:00
Andrew Kelley
d5bbd74871
allow C pointers to have alignment
...
clang/gcc support pointer alignment attribute:
https://clang.llvm.org/docs/AttributeReference.html#align-value
2019-02-14 20:04:13 -05:00