Commit Graph

161 Commits (9395162a7c41689bcd1c0c48f9eabffc1485fc74)

Author SHA1 Message Date
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 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
Andrew Kelley 459d72f873 fix compiler crash for invalid enum
closes #1079
closes #1147
2018-06-21 17:41:49 -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 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 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 3c12ba7180 update test cases 2018-06-17 04:32:57 -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 8dd24796c4 disallow implicit casts that break rules for optionals
closes #1102
2018-06-13 11:04:09 -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 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 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 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 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 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 0c16cd2d0e run zig fmt on the codebase
See #1003
2018-05-29 04:23:38 -04:00
Andrew Kelley c38b165db4 all tests passing with postfix deref syntax 2018-05-17 23:21:44 -04:00
Alexandros Naskos 255c0ef406 Resolved merge conflict. 2018-05-01 13:09:34 +03:00
Alexandros Naskos ff1c4e1f13 Added tests. 2018-05-01 13:00:39 +03:00
Jimmi Holst Christensen fba0347ec4 .ReturnType and @ArgType now emits errors on unresolved types
related: #846
2018-04-28 17:17:48 +02: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 c4840d78fb add test case for #936 2018-04-21 02:10:22 -04: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
Andrew Kelley 373b3586a1 inline functions must be stored in const or comptime var
closes #913
2018-04-12 16:26:23 -04:00
Andrew Kelley e48e707c32 allow integer and float literals to be passed to var params
closes #623
2018-04-11 14:47:37 -04:00
Andrew Kelley 6cb99fdac3 fix crash when compile error in analyzing @panic call 2018-03-27 15:07:45 -04:00
Andrew Kelley f885a1ab61 change async function call syntax
* instead of `async(allocator) call()`, now it is
   `async<allocator> call()`.
 * Fixes syntax ambiguity when leaving off the allocator
 * Fixes parse failure when call is a field access

This sets a precedent for using `<` to pass arguments
to a keyword. This will affect `enum`, `union`, and
`fn` (see #661)
2018-03-21 19:56:41 -04:00
Andrew Kelley efebb6d341 fix tests broken by previous commit 2018-03-14 03:37:54 -04:00
Andrea Orru c828c23f71 Tests for zero-bit field compiler error 2018-03-13 22:07:40 -07:00
Andrew Kelley 790aaeacae add compile error for using @tagName on extern union
closes #742
2018-03-07 14:35:48 -05:00
Andrew Kelley d96dd5bc32 fix missing compile error for returning error from void async function
closes #799
2018-03-06 21:44:27 -05:00
Andrew Kelley eff3530dfa var is no longer a pseudo-type, it is syntax
closes #779
2018-03-06 18:31:31 -05:00