You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sema: any fn type is compatible with any other fn type (params and result never compared) — garbage results, invalid MIR #1772
Sema.types_compatible accepts any fn type for any other fn type: for TY_FN against TY_FN both types_compatible_fast and types_compatible return callable_unsafe_coercion_ok — only unsafe-ness is compared, never the parameters or the result. (TY_EXTERN_FN does compare them, through fn_types_compatible.)
Prints 4294967287: the i32 result is read as an i64.
fn add1(x: i32) -> i32: x + 1
fn main:
let f: fn(i32) -> str = add1
print(f(1))
error: invalid MIR before codegen: use rvalue type is incompatible with assign destination (dest ty=399 kind=12, src ty=983 kind=12)
Sema accepted it; MIR's validator caught what Sema should have (D65: post-Sema invalid MIR is a compiler bug).
Where
src/Sema.w, types_compatible_fast (if exp_k == TypeKind.TY_FN and act_k == TypeKind.TY_FN: return self.callable_unsafe_coercion_ok(...)) and the same branch in types_compatible.
Note
Comparing fn types structurally everywhere may reject code that leans on the hole today (closures typed against inferred signatures, generic callables); it needs a sweep. The #1508 fix (a closure's declared -> T) checks the closure's declared result against the result its context expects itself (Sema.types_identical), so that path does not reach this hole.
Activity
D71 language rulings: @[flags] without repr, from_int on unit enums, …
Sema: an assignment an `unsafe:` or plain block yields as a body's ta…
test: capture_move's apply_void takes fn() -> Unit (it relied on #1772'…
build/selfhost.w: generated action fixtures take ctx: ActionCtx, the …
Sema: a fn value is assignable to a fn type only when the signatures …
Sema: an assignment an `unsafe:` or plain block yields as a body's ta…
test: capture_move's apply_void takes fn() -> Unit (it relied on #1772'…
build/selfhost.w: generated action fixtures take ctx: ActionCtx, the …
Sema: a fn value is assignable to a fn type only when the signatures …
Build driver: an action's declared contract is checked before every w…
Sema: an assignment an `unsafe:` or plain block yields as a body's ta…
test: capture_move's apply_void takes fn() -> Unit (it relied on #1772'…
build/selfhost.w: generated action fixtures take ctx: ActionCtx, the …
Sema: a fn value is assignable to a fn type only when the signatures …