Commit Graph

710 Commits

Author SHA1 Message Date
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