Commit Graph

21 Commits (29beb603b752928184f5f5e9f7479412de1e1951)

Author SHA1 Message Date
Andrew Kelley 29beb603b7 allow division and remainder operators sometimes
when the values are comptime known and the result would be the same,
allow `/` and `%` for signed integers and floats.

closes #365
2017-05-06 23:59:57 -04:00
Andrew Kelley 157af4332a builtin functions for division and remainder division
* add `@divTrunc` and `@divFloor` functions
 * add `@rem` and `@mod` functions
 * add compile error for `/` and `%` with signed integers
 * add `.bit_count` for float primitive types

closes #217
2017-05-06 23:13:12 -04:00
Andrew Kelley 866c841dd8 add compile error when unable to inline a function
See #38
2017-05-04 15:11:24 -04:00
Andrew Kelley 20b1491e6b implement while for nullables and error unions
See #357
2017-05-04 10:28:00 -04:00
Andrew Kelley 698829b772 change while syntax
Old:

```
while (condition; expression) {}
```

New:

```
while (condition) : (expression) {}
```

This is in preparation to allow nullable and
error union types as the condition. See #357
2017-05-03 18:12:07 -04:00
Andrew Kelley 644ea2dde9 remove test and try expressions in favor of if expressions
See #357
2017-05-03 17:23:11 -04:00
Andrew Kelley 0940d46c01 add compile error for shadowing variable
closes #360
2017-05-03 16:13:57 -04:00
Andrew Kelley 6756c27ca4 zig build: cache_root is relative to build_root 2017-05-03 16:13:57 -04:00
Andrew Kelley 17b935325e `@import("builtin")` instead of `@compileVar`
See #226
Closes #220
2017-05-01 13:12:38 -04:00
Andrew Kelley 458afb0ef9 phi instruction retains stack ptr hint 2017-04-27 23:40:43 -04:00
Andrew Kelley 2e512a0e6e add compile error for returning local variable address
closes #344
2017-04-27 19:40:35 -04:00
Josh Wolfe 08a871f625 defer requires expr to be void. closes #341 2017-04-23 22:33:06 -07:00
Josh Wolfe ac7971122d fix check-statement-is-void. add tests
see #291
2017-04-23 21:50:34 -07:00
Josh Wolfe c6605cba83 blocks check that their statements are void
closes #291

This changes the error message "return value ignored" to "expression value is ignored".
This is because this error also applies to {1;}, which has no function calls.

Also fix ignored expression values in std and test.
This caught a bug in debug.readAllocBytes where an early Eof error would have been missed.
See #219.
2017-04-23 21:15:15 -07:00
Josh Wolfe 14dfbd6ad3 remove redundant unreachable code error 2017-04-23 08:36:21 -07:00
Andrew Kelley ad9040443c new compile errors for setGlobalAlign and setGlobalSection builtins
if you try to use them on an external variable or function
then you get a compile error, since the alignment/section
is set externally in this case.

closes #244
2017-04-22 12:54:00 -04:00
Andrew Kelley 0cce115476 update syntax for try and nullable unwrapping
closes #285
2017-04-21 16:46:33 -04:00
Andrew Kelley e3c524c1d4 rename `@ptrcast` to `@ptrCast` to follow convention 2017-04-21 10:39:13 -04:00
Andrew Kelley 599215cee4 add compile error tests for offsetOf builtin 2017-04-20 10:57:41 -04:00
Andrew Kelley d1e01e43d3 convert assemble and link tests to zig build system 2017-04-19 14:00:12 -04:00
Andrew Kelley d0a17b6937 convert std lib tests to zig build system 2017-04-19 04:12:22 -04:00