Summary
Currently int(s) treats all string sources as fallible, requiring ?: even when s is a compile-time literal that cannot fail. The checker should distinguish compile-time-known strings from runtime inputs.
Changes
- Narrow fallibility detection in the checker:
- String literal / compile-time-known string → cast is infallible, no
?: required
- Runtime input (
io::in(), function params, variables) → keep fallible, ?: required
- Remove
? postfix propagation syntax (int? x = int(s)?)
Examples
string s = "42";
int x = int(s); // OK — compile-time literal
string age = io::in();
int y = int(age); // ERROR — runtime input, must use ?:
int z = int(age) ?: 0; // OK
Testing
- sema pass: literal string to numeric cast without
?:
- sema fail: runtime string to numeric cast without
?:
- sema fail:
? postfix propagation rejected
Summary
Currently
int(s)treats allstringsources as fallible, requiring?:even whensis a compile-time literal that cannot fail. The checker should distinguish compile-time-known strings from runtime inputs.Changes
?:requiredio::in(), function params, variables) → keep fallible,?:required?postfix propagation syntax (int? x = int(s)?)Examples
Testing
?:?:?postfix propagation rejected