| ... | @@ -207,7 +207,7 @@ pub fn analyzeFunctionDeclaration(s: *Sema) Error!Value { | ... | @@ -207,7 +207,7 @@ pub fn analyzeFunctionDeclaration(s: *Sema) Error!Value { |
| 207 | for (fn_decl.params.slice(&s.code), 0..) |param, i| { | 207 | for (fn_decl.params.slice(&s.code), 0..) |param, i| { |
| 208 | const src = s.inst_map.start.op(operandArgument(@intCast(i))); | 208 | const src = s.inst_map.start.op(operandArgument(@intCast(i))); |
| 209 | const ty = try s.resolveType(src, param); | 209 | const ty = try s.resolveType(src, param); |
| 210 | if (!ty.hasRuntimeRepresentation(s.ip)) { | 210 | if (!ty.hasPossibleRepresentation(s.ip)) { |
| 211 | return s.fail(.param_comptime_only, .{ | 211 | return s.fail(.param_comptime_only, .{ |
| 212 | .src = s.lazyNode(src), | 212 | .src = s.lazyNode(src), |
| 213 | .type = ty, | 213 | .type = ty, |
| ... | @@ -546,7 +546,7 @@ fn analyzeCodeInner(s: *Sema, in: Teg.Inst.Index) Error!Air.Inst.Ref { | ... | @@ -546,7 +546,7 @@ fn analyzeCodeInner(s: *Sema, in: Teg.Inst.Index) Error!Air.Inst.Ref { |
| 546 | } | 546 | } |
| 547 | } else { | 547 | } else { |
| 548 | for (call.args.slice(&s.code), 0..) |arg, i| { | 548 | for (call.args.slice(&s.code), 0..) |arg, i| { |
| 549 | const ref = try s.ensureValueRuntime( | 549 | const ref = try s.ensureValueDefinedRepresentation( |
| 550 | in.op(operandArgument(@intCast(i))), | 550 | in.op(operandArgument(@intCast(i))), |
| 551 | try s.resolveRef(arg), | 551 | try s.resolveRef(arg), |
| 552 | ); | 552 | ); |
| ... | @@ -574,7 +574,7 @@ fn analyzeCodeInner(s: *Sema, in: Teg.Inst.Index) Error!Air.Inst.Ref { | ... | @@ -574,7 +574,7 @@ fn analyzeCodeInner(s: *Sema, in: Teg.Inst.Index) Error!Air.Inst.Ref { |
| 574 | const scratch = try s.arena.alloc(Air.Inst.Ref, call.args.len); | 574 | const scratch = try s.arena.alloc(Air.Inst.Ref, call.args.len); |
| 575 | defer s.arena.free(scratch); | 575 | defer s.arena.free(scratch); |
| 576 | for (call.args.slice(&s.code), 0..) |arg, i| { | 576 | for (call.args.slice(&s.code), 0..) |arg, i| { |
| 577 | const ref = try s.ensureValueRuntime( | 577 | const ref = try s.ensureValueDefinedRepresentation( |
| 578 | in.op(operandArgument(@intCast(i))), | 578 | in.op(operandArgument(@intCast(i))), |
| 579 | try s.resolveRef(arg), | 579 | try s.resolveRef(arg), |
| 580 | ); | 580 | ); |
| ... | @@ -1213,7 +1213,7 @@ fn ensureValueRuntime(s: *Sema, src: InstOp, ref: Air.Inst.Ref) Error!Air.Inst.R | ... | @@ -1213,7 +1213,7 @@ fn ensureValueRuntime(s: *Sema, src: InstOp, ref: Air.Inst.Ref) Error!Air.Inst.R |
| 1213 | .string, | 1213 | .string, |
| 1214 | .void, | 1214 | .void, |
| 1215 | => {}, | 1215 | => {}, |
| 1216 | _ => if (!ty.hasRuntimeRepresentation(s.ip)) { | 1216 | _ => if (!ty.hasPossibleRepresentation(s.ip)) { |
| 1217 | return s.fail(.runtime_incompatible_type, .{ | 1217 | return s.fail(.runtime_incompatible_type, .{ |
| 1218 | .src = s.lazyNode(src), | 1218 | .src = s.lazyNode(src), |
| 1219 | .type = ty, | 1219 | .type = ty, |
| ... | @@ -1221,11 +1221,31 @@ fn ensureValueRuntime(s: *Sema, src: InstOp, ref: Air.Inst.Ref) Error!Air.Inst.R | ... | @@ -1221,11 +1221,31 @@ fn ensureValueRuntime(s: *Sema, src: InstOp, ref: Air.Inst.Ref) Error!Air.Inst.R |
| 1221 | }, | 1221 | }, |
| 1222 | } | 1222 | } |
| 1223 | }, | 1223 | }, |
| 1224 | else => {}, | 1224 | .index => { |
| | 1225 | const ty = s.typeOfRef(ref); |
| | 1226 | if (!ty.hasPossibleRepresentation(s.ip)) { |
| | 1227 | return s.fail(.runtime_incompatible_type, .{ |
| | 1228 | .src = s.lazyNode(src), |
| | 1229 | .type = ty, |
| | 1230 | }); |
| | 1231 | } |
| | 1232 | }, |
| 1225 | } | 1233 | } |
| 1226 | return ref; | 1234 | return ref; |
| 1227 | } | 1235 | } |
| 1228 | | 1236 | |
| | 1237 | fn ensureValueDefinedRepresentation(s: *Sema, src: InstOp, ref: Air.Inst.Ref) Error!Air.Inst.Ref { |
| | 1238 | const runtime = try s.ensureValueRuntime(src, ref); |
| | 1239 | const ty = s.typeOfRef(runtime); |
| | 1240 | if (!ty.hasDefinedRepresentation(s.ip)) { |
| | 1241 | return s.fail(.type_no_defined_representation, .{ |
| | 1242 | .src = s.lazyNode(src), |
| | 1243 | .type = ty, |
| | 1244 | }); |
| | 1245 | } |
| | 1246 | return runtime; |
| | 1247 | } |
| | 1248 | |
| 1229 | fn coerceArrayValue(s: *Sema, src: InstOp, value: Value, item_type: Type) !Value { | 1249 | fn coerceArrayValue(s: *Sema, src: InstOp, value: Value, item_type: Type) !Value { |
| 1230 | const array: InternPool.Tag.ArrayValue, var trail = value.valueData(s.ip, .array_value).getTrail(s.ip); | 1250 | const array: InternPool.Tag.ArrayValue, var trail = value.valueData(s.ip, .array_value).getTrail(s.ip); |
| 1231 | | 1251 | |