Commit 656cc33f8d

Andrew Kelley <andrew@ziglang.org>
2019-12-06 21:25:00
allow calling with a new stack to regress a bit
Calling with a new stack, with a runtime-known stack pointer (e.g. not a global variable) is regressed with this branch. It is now a compile-error, due to the Runtime Hint system not being smart enough to mix a compile-time modifier field with a runtime stack field. I'm OK with this regression because this feature is flawed (see #3268) and may be deleted from the language.
1 parent 71b7f4b
Changed files (4)
doc/langref.html.in
@@ -6870,16 +6870,6 @@ pub const CallOptions = struct {
         /// Equivalent to function call syntax.
         auto,
 
-        /// Asserts that the function call will not suspend. This allows a
-        /// non-async function to call an async function.
-        no_async,
-
-        /// The function call will return an async function frame instead of
-        /// the function's result, which is expected to then be awaited.
-        /// This is equivalent to using the `async` keyword in front of function
-        /// call syntax.
-        async_call,
-
         /// Prevents tail call optimization. This guarantees that the return
         /// address will point to the callsite, as opposed to the callsite's
         /// callsite. If the call is otherwise required to be tail-called
@@ -6890,6 +6880,10 @@ pub const CallOptions = struct {
         /// otherwise required to be inlined, a compile error is emitted instead.
         never_inline,
 
+        /// Asserts that the function call will not suspend. This allows a
+        /// non-async function to call an async function.
+        no_async,
+
         /// Guarantees that the call will be generated with tail call optimization.
         /// If this is not possible, a compile error is emitted instead.
         always_tail,
@@ -6938,7 +6932,6 @@ fn targetFunction(x: i32) usize {
 }
       {#code_end#}
       {#header_close#}
-
       {#header_close#}
 
       {#header_open|@cDefine#}
lib/std/builtin.zig
@@ -382,16 +382,6 @@ pub const CallOptions = struct {
         /// Equivalent to function call syntax.
         auto,
 
-        /// Asserts that the function call will not suspend. This allows a
-        /// non-async function to call an async function.
-        no_async,
-
-        /// The function call will return an async function frame instead of
-        /// the function's result, which is expected to then be awaited.
-        /// This is equivalent to using the `async` keyword in front of function
-        /// call syntax.
-        async_call,
-
         /// Prevents tail call optimization. This guarantees that the return
         /// address will point to the callsite, as opposed to the callsite's
         /// callsite. If the call is otherwise required to be tail-called
@@ -402,6 +392,10 @@ pub const CallOptions = struct {
         /// otherwise required to be inlined, a compile error is emitted instead.
         never_inline,
 
+        /// Asserts that the function call will not suspend. This allows a
+        /// non-async function to call an async function.
+        no_async,
+
         /// Guarantees that the call will be generated with tail call optimization.
         /// If this is not possible, a compile error is emitted instead.
         always_tail,
src/all_types.hpp
@@ -409,6 +409,9 @@ struct ZigValue {
     LLVMValueRef llvm_global;
 
     union {
+        // populated if special == ConstValSpecialLazy
+        LazyValue *x_lazy;
+
         // populated if special == ConstValSpecialStatic
         BigInt x_bigint;
         BigFloat x_bigfloat;
@@ -429,7 +432,6 @@ struct ZigValue {
         ConstPtrValue x_ptr;
         ConstArgTuple x_arg_tuple;
         Buf *x_enum_literal;
-        LazyValue *x_lazy;
 
         // populated if special == ConstValSpecialRuntime
         RuntimeHintErrorUnion rh_error_union;
@@ -770,16 +772,16 @@ struct AstNodeUnwrapOptional {
 // Must be synchronized with std.builtin.CallOptions.Modifier
 enum CallModifier {
     CallModifierNone,
-    CallModifierNoAsync,
-    CallModifierAsync,
     CallModifierNeverTail,
     CallModifierNeverInline,
+    CallModifierNoAsync,
     CallModifierAlwaysTail,
     CallModifierAlwaysInline,
     CallModifierCompileTime,
 
-    // This is an additional tag in the compiler, but not exposed in the std lib.
+    // These are additional tags in the compiler, but not exposed in the std lib.
     CallModifierBuiltin,
+    CallModifierAsync,
 };
 
 struct AstNodeFnCallExpr {
test/compile_errors.zig
@@ -45,9 +45,9 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
 
     cases.addCase(x: {
         var tc = cases.create("call with new stack on unsupported target",
+            \\var buf: [10]u8 align(16) = undefined;
             \\export fn entry() void {
-            \\    var buf: [10]u8 align(16) = undefined;
-            \\    @call(.{.stack = &buf}, foo);
+            \\    @call(.{.stack = &buf}, foo, .{});
             \\}
             \\fn foo() void {}
         , "tmp.zig:3:5: error: target arch 'wasm32' does not support calling with a new stack");