| ... | @@ -2461,7 +2461,8 @@ fn analyzeCall( | ... | @@ -2461,7 +2461,8 @@ fn analyzeCall( |
| 2461 | | 2461 | |
| 2462 | const gpa = sema.gpa; | 2462 | const gpa = sema.gpa; |
| 2463 | | 2463 | |
| 2464 | const is_comptime_call = block.is_comptime or modifier == .compile_time; | 2464 | const is_comptime_call = block.is_comptime or modifier == .compile_time or |
| | 2465 | func_ty_info.return_type.requiresComptime(); |
| 2465 | const is_inline_call = is_comptime_call or modifier == .always_inline or | 2466 | const is_inline_call = is_comptime_call or modifier == .always_inline or |
| 2466 | func_ty_info.cc == .Inline; | 2467 | func_ty_info.cc == .Inline; |
| 2467 | const result: Air.Inst.Ref = if (is_inline_call) res: { | 2468 | const result: Air.Inst.Ref = if (is_inline_call) res: { |
| ... | @@ -3609,6 +3610,8 @@ fn funcCommon( | ... | @@ -3609,6 +3610,8 @@ fn funcCommon( |
| 3609 | return mod.fail(&block.base, src, "TODO implement support for function prototypes to have alignment specified", .{}); | 3610 | return mod.fail(&block.base, src, "TODO implement support for function prototypes to have alignment specified", .{}); |
| 3610 | } | 3611 | } |
| 3611 | | 3612 | |
| | 3613 | is_generic = is_generic or bare_return_type.requiresComptime(); |
| | 3614 | |
| 3612 | const return_type = if (!inferred_error_set or bare_return_type.tag() == .generic_poison) | 3615 | const return_type = if (!inferred_error_set or bare_return_type.tag() == .generic_poison) |
| 3613 | bare_return_type | 3616 | bare_return_type |
| 3614 | else blk: { | 3617 | else blk: { |
| ... | @@ -5334,18 +5337,18 @@ fn analyzeArithmetic( | ... | @@ -5334,18 +5337,18 @@ fn analyzeArithmetic( |
| 5334 | ) CompileError!Air.Inst.Ref { | 5337 | ) CompileError!Air.Inst.Ref { |
| 5335 | const lhs_ty = sema.typeOf(lhs); | 5338 | const lhs_ty = sema.typeOf(lhs); |
| 5336 | const rhs_ty = sema.typeOf(rhs); | 5339 | const rhs_ty = sema.typeOf(rhs); |
| 5337 | if (lhs_ty.zigTypeTag() == .Vector and rhs_ty.zigTypeTag() == .Vector) { | 5340 | const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(); |
| | 5341 | const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(); |
| | 5342 | if (lhs_zig_ty_tag == .Vector and rhs_zig_ty_tag == .Vector) { |
| 5338 | if (lhs_ty.arrayLen() != rhs_ty.arrayLen()) { | 5343 | if (lhs_ty.arrayLen() != rhs_ty.arrayLen()) { |
| 5339 | return sema.mod.fail(&block.base, src, "vector length mismatch: {d} and {d}", .{ | 5344 | return sema.mod.fail(&block.base, src, "vector length mismatch: {d} and {d}", .{ |
| 5340 | lhs_ty.arrayLen(), | 5345 | lhs_ty.arrayLen(), rhs_ty.arrayLen(), |
| 5341 | rhs_ty.arrayLen(), | | |
| 5342 | }); | 5346 | }); |
| 5343 | } | 5347 | } |
| 5344 | return sema.mod.fail(&block.base, src, "TODO implement support for vectors in zirBinOp", .{}); | 5348 | return sema.mod.fail(&block.base, src, "TODO implement support for vectors in zirBinOp", .{}); |
| 5345 | } else if (lhs_ty.zigTypeTag() == .Vector or rhs_ty.zigTypeTag() == .Vector) { | 5349 | } else if (lhs_zig_ty_tag == .Vector or rhs_zig_ty_tag == .Vector) { |
| 5346 | return sema.mod.fail(&block.base, src, "mixed scalar and vector operands to binary expression: '{}' and '{}'", .{ | 5350 | return sema.mod.fail(&block.base, src, "mixed scalar and vector operands to binary expression: '{}' and '{}'", .{ |
| 5347 | lhs_ty, | 5351 | lhs_ty, rhs_ty, |
| 5348 | rhs_ty, | | |
| 5349 | }); | 5352 | }); |
| 5350 | } | 5353 | } |
| 5351 | | 5354 | |
| ... | @@ -5365,7 +5368,9 @@ fn analyzeArithmetic( | ... | @@ -5365,7 +5368,9 @@ fn analyzeArithmetic( |
| 5365 | const is_float = scalar_tag == .Float or scalar_tag == .ComptimeFloat; | 5368 | const is_float = scalar_tag == .Float or scalar_tag == .ComptimeFloat; |
| 5366 | | 5369 | |
| 5367 | if (!is_int and !(is_float and floatOpAllowed(zir_tag))) { | 5370 | if (!is_int and !(is_float and floatOpAllowed(zir_tag))) { |
| 5368 | return sema.mod.fail(&block.base, src, "invalid operands to binary expression: '{s}' and '{s}'", .{ @tagName(lhs_ty.zigTypeTag()), @tagName(rhs_ty.zigTypeTag()) }); | 5371 | return sema.mod.fail(&block.base, src, "invalid operands to binary expression: '{s}' and '{s}'", .{ |
| | 5372 | @tagName(lhs_zig_ty_tag), @tagName(rhs_zig_ty_tag), |
| | 5373 | }); |
| 5369 | } | 5374 | } |
| 5370 | | 5375 | |
| 5371 | if (try sema.resolveMaybeUndefVal(block, lhs_src, casted_lhs)) |lhs_val| { | 5376 | if (try sema.resolveMaybeUndefVal(block, lhs_src, casted_lhs)) |lhs_val| { |
| ... | @@ -6164,6 +6169,10 @@ fn analyzeRet( | ... | @@ -6164,6 +6169,10 @@ fn analyzeRet( |
| 6164 | const casted_operand = if (!need_coercion) operand else op: { | 6169 | const casted_operand = if (!need_coercion) operand else op: { |
| 6165 | const func = sema.func.?; | 6170 | const func = sema.func.?; |
| 6166 | const fn_ty = func.owner_decl.ty; | 6171 | const fn_ty = func.owner_decl.ty; |
| | 6172 | // TODO: In the case of a comptime/inline function call of a generic function, |
| | 6173 | // this needs to be the resolved return type based on the function parameter type |
| | 6174 | // expressions being evaluated with comptime arguments passed in. Otherwise, this |
| | 6175 | // ends up being .generic_poison and failing the comptime/inline function call analysis. |
| 6167 | const fn_ret_ty = fn_ty.fnReturnType(); | 6176 | const fn_ret_ty = fn_ty.fnReturnType(); |
| 6168 | break :op try sema.coerce(block, fn_ret_ty, operand, src); | 6177 | break :op try sema.coerce(block, fn_ret_ty, operand, src); |
| 6169 | }; | 6178 | }; |
| ... | @@ -9093,7 +9102,7 @@ fn typeHasOnePossibleValue( | ... | @@ -9093,7 +9102,7 @@ fn typeHasOnePossibleValue( |
| 9093 | | 9102 | |
| 9094 | .inferred_alloc_const => unreachable, | 9103 | .inferred_alloc_const => unreachable, |
| 9095 | .inferred_alloc_mut => unreachable, | 9104 | .inferred_alloc_mut => unreachable, |
| 9096 | .generic_poison => unreachable, | 9105 | .generic_poison => return error.GenericPoison, |
| 9097 | }; | 9106 | }; |
| 9098 | } | 9107 | } |
| 9099 | | 9108 | |