Commit Graph

116 Commits (66fec3a3d726733b162761211dee58e896370e95)

Author SHA1 Message Date
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
Andrew Kelley 5d5820029d fix broken tests from previous commit 2018-03-06 16:46:45 -05:00
Andrew Kelley 07e47c058c ptrCast builtin now gives an error for removing const qualifier
closes #384
2018-03-06 16:37:03 -05:00
Ben Noordhuis 90598b4631 fix assert on self-referencing function ptr field
The construct `struct S { f: fn(S) void }` is not legal because structs
are not copyable but it should not result in an ICE.

Fixes #795.
2018-02-28 00:56:00 +01:00
Andrew Kelley 72ca2b214d ability to slice an undefined pointer at compile time if the len is 0 2018-02-16 15:22:29 -05:00
Andrew Kelley 9fa35adbd4 fix sometimes not type checking function parameters
closes #774

regression introduced in cfb2c67692
2018-02-14 16:24:43 -05:00
Andrew Kelley e7bf8f3f04 fix compiler crash switching on global error with no else 2018-02-09 13:49:58 -05:00
Andrew Kelley 916d24cd21 add compile error tests for error sets 2018-02-08 23:44:21 -05:00
Andrew Kelley 54c06bf715 error sets: runtime safety for int-to-err and err set cast 2018-02-08 21:54:44 -05:00
Andrew Kelley f9be970375 Merge remote-tracking branch 'origin/master' into error-sets 2018-02-08 20:45:26 -05:00
Andrew Kelley 0d5ff6f462 error sets - most tests passing 2018-02-08 02:08:45 -05:00
Andrew Kelley 44d8d654a0 fix test failure, organize code, add new compile error 2018-02-05 09:26:39 -05:00
Andrew Kelley 5f518dbeb9 *WIP* error sets converting std lib 2018-01-31 22:48:40 -05:00
Andrew Kelley 44f38b04b0 fix assertion fail when using global var number literal
closes #697
2018-01-31 11:13:39 -05:00
Andrew Kelley 40ca39d3d5 fix error message mentioning unreachable instead of noreturn 2018-01-31 01:44:52 -05:00
Andrew Kelley 3ef6a00bb8 add compile error for duplicate struct, enum, union fields
closes #730
2018-01-30 11:52:03 -05:00
Andrew Kelley 1c60f31450 add compile error for calling naked function 2018-01-29 14:01:12 -05:00
Andrew Kelley abe6c2d585 allow packed containers in extern functions 2018-01-29 10:57:09 -05:00
Andrew Kelley ad3e2a5da0 fix compiler crash on function with invalid return type
closes #722
2018-01-26 10:37:18 -05:00
Andrew Kelley 3671582c15 syntax: functions require return type. remove `->`
The purpose of this is:

 * Only one way to do things
 * Changing a function with void return type to return a possible
   error becomes a 1 character change, subtly encouraging
   people to use errors.

See #632

Here are some imperfect sed commands for performing this update:

remove arrow:

```
sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig")
```

add void:

```
sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig")
```

Some cleanup may be necessary, but this should do the bulk of the work.
2018-01-25 04:10:11 -05:00
Andrew Kelley e5bc5873d7 rename "debug safety" to "runtime safety"
closes #437
2018-01-25 01:46:12 -05:00
Andrew Kelley cf39819478 add new kind of test: generating .h files. and more
* docgen supports obj_err code kind for demonstrating
   errors without explicit test cases
 * add documentation for `extern enum`. See #367
 * remove coldcc keyword and add @setIsCold. See #661
 * add compile errors for non-extern struct, enum, unions
   in function signatures
 * add .h file generation for extern struct, enum, unions
2018-01-22 22:24:07 -05:00
Andrew Kelley 5b7ae86af4 fix crash when switching on enum with 1 field and no switch prongs
closes #712
2018-01-21 14:44:24 -05:00
Andrew Kelley ea623f2d39 all doc code examples are now tested
improve color scheme of docs
make docs depend on no external files
fix broken example code in docs

closes #465
2018-01-19 03:21:47 -05:00
Andrew Kelley 4b64c777ee add compile error for shifting by negative comptime integer
closes #698
2018-01-18 17:47:21 -05:00
Andrew Kelley 0fc645ab70 emit a compile error for @panic called at compile time
closes #706
2018-01-18 17:15:36 -05:00
Andrew Kelley 7b57454cc1 clean up error return tracing
* error return tracing is disabled in release-fast mode
 * add @errorReturnTrace
 * zig build API changes build return type from `void` to `%void`
 * allow `void`, `noreturn`, and `u8` from main. closes #535
2018-01-15 00:01:02 -05:00
Andrew Kelley 3c094116aa remove %% prefix operator
See #632
closes #545
closes #510

this makes #651 higher priority
2018-01-09 00:51:51 -05:00
Andrew Kelley 632d143bff replace `a %% b` with `a catch b`
See #632

better fits the convention of using keywords for control flow
2018-01-07 17:28:20 -05:00
Andrew Kelley 66717db735 replace `%return` with `try`
See #632

better fits the convention of using keywords for control flow
2018-01-07 16:53:13 -05:00
Andrew Kelley bb39e503c0 fix struct inside function referencing local const
closes #672

the crash and compile errors are fixed but structs
inside functions still get named after the functions
they're in. this will be fixed later.
2018-01-07 00:28:37 -05:00
Andrew Kelley d917815d81 explicitly return from blocks
instead of last statement being expression value

closes #629
2017-12-22 00:50:30 -05:00
Andrew Kelley 8bc523219c add labeled loops, labeled break, labeled continue. remove goto
closes #346
closes #630

regression: translate-c can no longer translate switch statements.
after #629 we can ressurect and modify the code to utilize arbitrarily
returning from blocks.
2017-12-20 23:00:19 -05:00
Andrew Kelley 1cc450e6e7 fix assert when wrapping zero bit type in nullable
closes #659
2017-12-19 18:21:42 -05:00
Andrew Kelley 9d9201c3b4 bring back code that uses export and fix tests
partial revert of 1fdebc1dc4
2017-12-19 02:39:43 -05:00
Andrew Kelley 1fdebc1dc4 wip export rewrite 2017-12-18 09:59:57 -05:00
Andrew Kelley 960914a073 add implicit cast from enum to union
when the enum is the tag type of the union and is comptime known
to be of a void field of the union

See #642
2017-12-05 20:46:58 -05:00
Andrew Kelley 63a2f9a8b2 fix casting integer literal to enum 2017-12-05 18:09:22 -05:00
Andrew Kelley 05d9f07541 more tests for unions
See #618
2017-12-04 00:56:27 -05:00
Andrew Kelley fce435db26 fix abi alignment of union-enums not counting tag type
add more tests for unions

See #618
2017-12-04 00:32:12 -05:00
Andrew Kelley 0ad1239522 rework enums and unions and their relationship to each other
* @enumTagName renamed to @tagName and it works on enums and
   union-enums
 * Remove the EnumTag type. Now there is only enum and union,
   and the tag type of a union is always an enum.
 * unions support specifying the tag enum type, and they support
   inferring an enum tag type.
 * Enums no longer support field types but they do support
   setting the tag values. Likewise union-enums when inferring
   an enum tag type support setting the tag values.
 * It is now an error for enums and unions to have 0 fields.
 * switch statements support union-enums

closes #618
2017-12-03 20:43:56 -05:00
Andrew Kelley 137c8f5e8a ability to set tag values of enums
also remove support for enums with 0 values

closes #305
2017-12-02 22:32:39 -05:00
Andrew Kelley 98237f7c0b casting between integer and enum only works via tag type
See #305
2017-12-02 17:12:37 -05:00
Andrew Kelley b62e2fd870 ability to specify tag type of enums
see #305
2017-11-30 22:08:11 -05:00
Andrew Kelley a2afcae9ff fix crash when constant inside comptime function has compile error
closes #625
2017-11-25 18:16:33 -05:00
Andrew Kelley f276fd0f37 basic union support
See #144
2017-11-15 13:04:18 -05:00