fix(codegen): fail loudly on IsArrayAccess fall-through in both backends
The array-field-subscript read path (Rec.Arr[I]) in EmitExpr dispatches on the field's type kind — dynarray, static array, open array — with no final else. A field kind outside those three would fall through with Result unassigned (QBE: garbage temp name) or a stale %rax (native: silent wrong value). Unreachable today: the semantic pass only sets IsArrayAccess for those three kinds. But the invariant lives in a different unit, so add an explicit raise in both backends to turn any future mismatch into a compile-time internal error instead of silently wrong code.
This commit is contained in:
parent
35f8ff5970
commit
b776ceb5dd
|
|
@ -5668,7 +5668,11 @@ begin
|
|||
Exit;
|
||||
Self.EmitLoadVar('(%rax)',
|
||||
TOpenArrayTypeDesc(FAE.FieldInfo.TypeDesc).ElementType);
|
||||
end;
|
||||
end
|
||||
else
|
||||
raise ENativeCodeGenError.Create(Format(
|
||||
'IsArrayAccess on non-array field ''%s'' (kind %d) at line %d',
|
||||
[FAE.FieldName, Ord(FAE.FieldInfo.TypeDesc.Kind), FAE.Line]));
|
||||
Exit;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -10695,7 +10695,12 @@ begin
|
|||
L := AllocTemp();
|
||||
EmitLine(Format(' %s =%s %s %s', [L, QType, LoadInstr, T]));
|
||||
Exit(L);
|
||||
end;
|
||||
end
|
||||
else
|
||||
raise ECodeGenError.Create(Format(
|
||||
'IsArrayAccess on non-array field ''%s'' (kind %d) at line %d',
|
||||
[FldAccess.FieldName, Ord(FldAccess.FieldInfo.TypeDesc.Kind),
|
||||
FldAccess.Line]));
|
||||
end
|
||||
else if FldAccess.PropRead <> nil then
|
||||
begin
|
||||
|
|
|
|||
Loading…
Reference in a new issue