Commit Graph

769 Commits

Author SHA1 Message Date
Andrew Kelley
9c8dfadbb1 add compile error for casting const array to mutable slice
See #1565
2018-09-20 12:24:51 -04:00
Andrew Kelley
f8fe517d12 better string literal caching implementation
We were caching the ConstExprValue of string literals,
which works if you can never modify ConstExprValues.
This premise is broken with `comptime var ...`.

So I implemented an optimization in ConstExprValue
arrays, where it stores a `Buf *` directly rather
than an array of ConstExprValues for the elements,
and then similar to array of undefined, it is
expanded into the canonical form when necessary.
However many operations can happen directly on the
`Buf *`, which is faster.

Furthermore, before a ConstExprValue array is expanded
into canonical form, it removes itself from the string
literal cache. This fixes the issue, because before an
array element is modified it would have to be expanded.

closes #1076
2018-09-20 11:04:31 -04:00
Andrew Kelley
345f8db1c4 fix optional pointer to empty struct incorrectly being non-null
closes #1178
2018-09-18 17:51:50 -04:00
Andrew Kelley
c1af360532 add compile error for slice.*.len
closes #1372
2018-09-18 16:32:40 -04:00
Andrew Kelley
8c77c5705f implementation for bitcasting extern enum type to c_int
closes #1036
2018-09-18 15:00:14 -04:00
Andrew Kelley
5fd3af9dc6 fix implicit cast of packed struct field to const ptr
closes #966
2018-09-18 14:34:30 -04:00
Andrew Kelley
1fc2019031 fix @embedFile reading garbage memory
closes #1547
2018-09-18 10:25:57 -04:00
Andrew Kelley
d353d5aef8 fix @bytesToSlice on a packed struct
closes #1551
2018-09-18 09:49:57 -04:00
Andrew Kelley
b16229da1d add compile error for @ptrCast 0 bit type to non-0 bit type 2018-09-17 19:41:11 -04:00
Andrew Kelley
78a9a465a3 add compile error for non-optional types compared against null
closes #1539
2018-09-17 18:58:50 -04:00
Andrew Kelley
6c71e9a54d fix crash when bit shifting a u1 2018-09-17 18:44:45 -04:00
Andrew Kelley
cf9200b815 dereferencing a *u0 is comptime-known to be 0 2018-09-17 18:13:38 -04:00
Andrew Kelley
3f776af3fa fix alignment of structs
closes #1248
closes #1052
closes #1154
2018-09-14 19:08:59 -04:00
Andrew Kelley
639c381128 fix coroutine alignment
zig returned the wrong alignment for coroutine promises
in some cases
2018-09-14 13:55:45 -04:00
Andrew Kelley
c06a61e9bf remove this. add @This().
closes #1283
2018-09-13 16:34:33 -04:00
Andrew Kelley
7c3636aaa3 remove the scope parameter of setFloatMode
also document that scopes inherit this value. See #367
See #1283
2018-09-13 15:46:34 -04:00
Andrew Kelley
ac0cda8df8 add compile error for merging non- error sets
closes #1509
2018-09-13 13:48:41 -04:00
Andrew Kelley
22e39e1e5a fix tagged union with only 1 field tripping assertion
closes #1495

now the tag type of an enum with only 1 item is comptime_int.
2018-09-13 13:33:11 -04:00
Andrew Kelley
ff0b7fe29a error messages for attempted cache when zig cannot perfectly do it 2018-09-11 22:59:40 -04:00
Andrew Kelley
4af844732a Merge remote-tracking branch 'origin/master' into stage1-caching 2018-09-11 15:56:04 -04:00
Andrew Kelley
67735c6f15 ability to disable cache. off by default except for...
...zig run, zig build, compiler_rt.a, and builtin.a
2018-09-11 00:32:40 -04:00
Andrew Kelley
52f4e934a9 fix llvm assertion and missing compile error 2018-09-10 22:44:27 -04:00
Andrew Kelley
32be6e9b2a caching is working
* add almost all the input parameter state to the hash
   - missing items are the detected MSVC installation on Windows
     and detected libc installation on POSIX
   - also missing are C files and .h files that libclang finds
 * artifacts are created in global cache directory instead of
   zig-cache.
   - exception: builtin.zig is still in zig-cache
 * zig run uses the new cache correctly
 * zig run uses execv on posix systems
2018-09-10 13:46:23 -04:00
Andrew Kelley
b18af37c57 fix crash when var init has compile error
and then the var is referenced

closes #1483
2018-09-07 15:17:24 -04:00
Andrew Kelley
6632d85e5f stage1: improve handling of generic fn proto type expr
closes #902
2018-09-05 21:21:59 -04:00
Andrew Kelley
1d8b8ad687 add compile error for using outer scoped runtime variables
from a fn defined inside it. closes #876
2018-09-05 20:32:06 -04:00
Andrew Kelley
8400163e02 stage1: rename more TypeTableEntry types to ZigType 2018-09-05 18:42:56 -04:00
Andrew Kelley
1f5c7ff4d7 stage1: rename VariableTableEntry to ZigVar 2018-09-05 18:35:57 -04:00
Andrew Kelley
3500d32db5 stage1: rename FnTableEntry to ZigFn 2018-09-05 18:34:33 -04:00
Andrew Kelley
db882e5d63 stage1: rename TypeTableEntry to ZigType 2018-09-05 18:33:07 -04:00
Andrew Kelley
b517bea734 allow comptime_int to @floatToInt 2018-09-05 18:01:48 -04:00
hfcc
768d1fc539 Added compilation error when a non-float is given to @floatToInt() 2018-09-05 23:31:25 +02:00
Andrew Kelley
c87a576cb5 stage1 compile error instead of crashing for unsupported comptime ptr cast
See #955
2018-09-05 15:53:36 -04:00
Andrew Kelley
a76a72469b stage1: fix crash when invalid type used in array type
closes #1186
2018-09-05 10:43:35 -04:00
Andrew Kelley
b35c74ea4c stage1: use os_path_resolve instead of os_path_real
to canonicalize imports.

This means that softlinks can represent different files,
but referencing the same absolute path different ways
still references the same import.
2018-09-04 23:17:38 -04:00
Andrew Kelley
2bf1b6840d port std.os.path.resolve to stage1 2018-09-04 22:45:20 -04:00
Andrew Kelley
869167fc6d compile error for @noInlineCall on an inline fn
closes #1133
2018-09-04 17:38:48 -04:00
Andrew Kelley
cbb3f1d76c ir: consistent error checking for br and cond_br instructions 2018-09-04 16:58:19 -04:00
Andrew Kelley
68db9d5074 add compile error for comptime control flow inside runtime block
closes #834
2018-09-04 15:28:35 -04:00
Andrew Kelley
36828a2e6a fix incorrect variable ref count
regression introduced by e82cd53df4
2018-09-04 12:50:02 -04:00
Andrew Kelley
bc88ef2dc3 compile errors for unimplemented minValue/maxValue builtins 2018-09-03 22:47:23 -04:00
Andrew Kelley
e82cd53df4 fix incorrect value for inline loop
09cc1dc660 failed to handle mem_slot_index correctly

closes #1436
2018-09-03 21:24:20 -04:00
Andrew Kelley
a11e73bee2 compile error instead of segfault for unimplemented feature
closes #1103
2018-09-03 12:38:24 -04:00
Andrew Kelley
2a9329c998 better anonymous struct naming
this makes anonymous structs inherit the name of the function they are in
only when they are the return expression.

also document the behavior and provide examples.

closes #1243
2018-09-03 11:32:39 -04:00
Andrew Kelley
95636c7e5f ability to @ptrCast to *void
fixes #960
2018-09-03 00:04:12 -04:00
Andrew Kelley
09cc1dc660 fix crash when var in inline loop has different types
closes #917
closes #845
closes #741
closes #740
2018-08-28 15:24:28 -04:00
Andrew Kelley
45d9d9f953 minor fixups 2018-08-27 18:31:28 -04:00
raulgrell
e2a9f2ef98 Allow implicit cast from *T and [*]T to ?*c_void 2018-08-27 23:13:57 +01:00
Andrew Kelley
009e90f446 fix @typeInfo unable to distinguish compile error vs no-payload
closes #1421
closes #1426
2018-08-27 17:13:34 -04:00
Andrew Kelley
68e2794e15 ir: const_ptr_pointee asserts that its return value is non-null 2018-08-26 13:13:26 -04:00