Several Display impls currently panic at runtime when given invalid type combinations:
Instr::Cmp panics on Type::Aggregate (aggregate types can't be compared)
Instr::Store panics on Type::Aggregate
Instr::Load panics on Type::Byte/Type::Halfword (ambiguous sub-word load) and Type::Aggregate
Statement::Assign panics on non-Value::Temporary targets
These are programmer errors caught at format-time, but ideally the type system would prevent constructing these invalid states in the first place. For example:
Statement::Assign could take a String (temporary name) instead of Value, since only Temporary is valid
Instr::Cmp / Instr::Load / Instr::Store could use a restricted type enum that excludes Aggregate (and for Load, also Byte/Halfword)
This would shift these checks from runtime panics to compile-time errors.
Several
Displayimpls currently panic at runtime when given invalid type combinations:Instr::Cmppanics onType::Aggregate(aggregate types can't be compared)Instr::Storepanics onType::AggregateInstr::Loadpanics onType::Byte/Type::Halfword(ambiguous sub-word load) andType::AggregateStatement::Assignpanics on non-Value::TemporarytargetsThese are programmer errors caught at format-time, but ideally the type system would prevent constructing these invalid states in the first place. For example:
Statement::Assigncould take aString(temporary name) instead ofValue, since onlyTemporaryis validInstr::Cmp/Instr::Load/Instr::Storecould use a restricted type enum that excludesAggregate(and forLoad, alsoByte/Halfword)This would shift these checks from runtime panics to compile-time errors.