Commit Graph

1150 Commits

Author SHA1 Message Date
LemonBoy
7a1cde7206 Fix wrong error code being returned in enum analisys
Fixes the assertion failure seen in #4233
2020-01-19 13:28:27 -05:00
LemonBoy
c53d94e512 Prevent crash with empty non-exhaustive enum 2020-01-18 15:13:21 +01:00
Vexu
6c8f01dcde correct field count 2020-01-16 22:52:10 +02:00
Vexu
cb257b4e11 allow non-exhaustive enums with no fields 2020-01-16 09:23:26 +02:00
Vexu
d84569895c turn panics into compile errors, require at least 1 field in non-exhaustive enum 2020-01-16 09:04:11 +02:00
Vexu
5c2238fc4a small fixes
* error for '_' prong on exhaustive enum
* todo panic for `@tagName`  on non-exhaustive enum
* don't require '_' field on tagged unions
2020-01-15 22:09:19 +02:00
Vexu
f3d174aa61 require size for non-exhaustive enums 2020-01-15 21:38:11 +02:00
Vexu
6fd0dddf18 implement non-exhaustive enums 2020-01-15 20:24:59 +02:00
LemonBoy
50754ba336 Fix ICE when BoundFn are passed as parameters
Closes #4022
Closes #3699
2020-01-14 13:09:23 -05:00
Andrew Kelley
4f9739189e add an extra assert 2020-01-13 14:48:43 -05:00
LemonBoy
9cc7fb66bc Don't special-case builtin too much
Let's use the usual declaration-searching mechanism that resolves the
`usingnamespace` declarations on the go instead of directly peeking into
the symbol table.

Fixes #4134
2020-01-10 16:44:15 -05:00
LemonBoy
5ab5de89c0 New @export() handling
Use a struct as second parameter to be future proof (and also allows to
specify default values for the parameters)

Closes #2679 as it was just a matter of a few lines of code.
2020-01-09 13:43:06 -05:00
LemonBoy
27b290f312 Propagate more failures upwards
Fixes #4112
2020-01-08 17:25:00 -05:00
Andrew Kelley
be2483c576 fix test suite regressions 2020-01-06 18:20:31 -05:00
Andrew Kelley
5951b79af4 remove stdcallcc, extern, nakedcc from stage1; zig fmt rewrites 2020-01-06 15:23:05 -05:00
Andrew Kelley
0a9daeb37e Merge branch 'cc-work' of https://github.com/LemonBoy/zig into LemonBoy-cc-work 2020-01-06 14:07:56 -05:00
LemonBoy
b91eaba38c Correct evaluation of optional type alignment
The lazy logic was too oversimplified and produced a different result
than the one computed later causing all kinds of problems.

Closes #4013
2020-01-03 17:41:55 -05:00
LemonBoy
0ccac79c8e Implement Thiscall CC 2020-01-02 18:57:08 +01:00
LemonBoy
271fc6a247 Catch more errors during the type resolution phase
Returning the uninitialized/stale error condition made the compiler turn
a blind eye to some problems.
2020-01-02 18:53:20 +01:00
LemonBoy
563d9ebfe5 Implement the callconv() annotation 2020-01-02 18:53:16 +01:00
Andrew Kelley
a05150e92d fix comparing comptime_int against undefined literal
closes #4004
2019-12-30 19:08:57 -05:00
LemonBoy
28a8ded95a Resolve more types as needed
Closes #3994
2019-12-30 17:45:09 -05:00
Andrew Kelley
ad92227516 report compile errors instead of crashing when frame is invalid 2019-12-22 17:09:11 -05:00
LemonBoy
d8499f7abe Make sure the fields array is always non-null
Fixes #3497
2019-12-17 15:45:22 -05:00
Andrew Kelley
9468d63819 allow comparison of any numeric types 2019-12-16 11:09:10 -05:00
Vexu
0f38410ea6 improve extern enum 2019-12-15 19:28:53 -05:00
LemonBoy
f1407b4b7e Generate the fn pointers into the correct address space
Fixes #3645
2019-12-15 14:42:53 -05:00
Andrew Kelley
fff3c1fff4 un-special-case startup code in the std lib
Previously, the compiler had special logic to determine whether to
include the startup code, which was in `std/special/start.zig`. Now,
the file is moved to `std/start.zig`, and there is no special logic
in the compiler. Instead, the standard library unconditionally imports
the `start.zig` file, which then has a `comptime` block that does the
logic of determining what, if any, start symbols to export. Instead of
`start.zig` being in its own special package, it is just another normal
file that is part of the standard library.

`std.builtin.TestFn` is now part of the standard library rather than
specially generated by the compiler.
2019-12-12 18:33:44 -05:00
Robin Voetter
f0ee0688f2 Replace typeOf with TypeOf in stage0 2019-12-10 11:09:30 -05:00
Andrew Kelley
a3f6a58c77 remove var args from the language
closes #208
2019-12-09 15:27:27 -05:00
Andrew Kelley
5874cb04bd implement tuple concatenation 2019-12-08 22:44:41 -05:00
Andrew Kelley
6504c5098e tuple detection does not require AST node 2019-12-08 18:39:52 -05:00
LemonBoy
d5e788072d Make array types (quasi-)lazy
Fixes #3843
2019-12-08 17:29:59 -05:00
Andrew Kelley
1cb19d1a46 fix anon struct literal field initialized with fn call 2019-12-08 17:28:34 -05:00
Andrew Kelley
fe8d65556d add syntax for comptime struct fields 2019-12-08 12:26:20 -05:00
Andrew Kelley
119ed128c0 implement comptime struct fields 2019-12-08 12:26:20 -05:00
Andrew Kelley
343987cd05 remove @inlineCall from zig 2019-12-06 14:12:01 -05:00
Andrew Kelley
1f602fe8c5 implement @call
closes #3732
2019-12-05 17:07:15 -05:00
Vexu
a0ca30ce01 move more startup code to std lib 2019-12-03 12:50:18 -05:00
LemonBoy
fd7c7be33c Pick up WinMain with proper CC 2019-12-03 12:49:08 -05:00
Andrew Kelley
78811ff4ac Merge remote-tracking branch 'origin/kill-ConstGlobalRefs' into remove-array-type-coercion 2019-12-01 09:58:32 -05:00
Andrew Kelley
4b6740e19d sometimes free stuff from Zig IR pass 1
Total bytes used in stage1 std lib tests:
3.418 -> 3.198 GiB (saving 225 MiB)

There's still this from pass 1 not getting freed:
Const: 6909049 items, 72 bytes each, total 474.407 MiB

This is due to 2 things hanging on to references to IrAnalyze pointers:
 * ZigVar->owner_exec->analysis
 * LazyValue->ira

The LazyValue one could be solved by memoizing the results after the
lazy value is resolved, and then it could unref the IrAnalyze.

ZigVars that are determined to be comptime const, could have their
const_value set to that value, instead of using the mem_slot_index
mechanism. This would prevent an IrAnalyze ref in some cases.
2019-12-01 01:13:21 -05:00
Andrew Kelley
b5df18c8fd inline ConstGlobalRefs into ZigValue
Having ConstGlobalRefs be a pointer in ZigValue was a hack that caused
plenty of bugs. It was used to work around difficulties in type coercing
array values into slices.

However, after #3787 is merged, array values no longer type coerce into
slices, and so this provided an opportunity to clean up the code.

This has the nice effect of reducing stage1 peak RAM usage during the
std lib tests from 3.443 GiB to 3.405 GiB (saving 39 MiB).

There is one behavior test failing in this branch, which I plan to debug
after merging #3787.
2019-12-01 00:29:16 -05:00
Andrew Kelley
85e1e3b95f Merge pull request #3284 from Sahnvour/export_variables
Improved support for exporting variables
2019-11-30 00:25:52 -05:00
Michael Dusan
6b7e1085e3 Merge pull request #3774 from mikdusan/stage1-intern-housekeeping
stage1: consolodate interning
2019-11-25 19:19:32 -05:00
Andrew Kelley
4261fa3c49 move logic to the appropriate layers; add new compile error 2019-11-25 18:46:17 -05:00
Michael Dusan
6c89f96df1 stage1: consolodate interning
- merge const_void_val → intern.x_void
- move const_zero_byte → intern.zero_byte
- wrap intern access
2019-11-25 17:18:56 -05:00
Michael Dusan
8f3e972da6 unembed ZigValue from IrInstruction 2019-11-25 15:04:39 -05:00
Michael Dusan
acd95546b7 rename ConstExprValue → ZigValue 2019-11-25 15:04:29 -05:00
Andrew Kelley
29e438fd1f more sentinel-terminated pointers std lib integration
See #3767
2019-11-25 00:43:36 -05:00