solidity-lean/SolidCore/Witness/DeleteLocalFnptrConditional.lean
Daniel Robinson 87b9aa3fd6
fix(fnptr-alias): a local internal fn-pointer conditionally deleted/reassigned inside a nested branch is no longer statically inlined to its declaration-time target — the call dispatches on the runtime pointer and Panic(0x51)s when deleted (#27)
The internal-function-pointer static alias-inlining pre-pass established
`f -> a` at `function(...) internal f = a;` and elided the declaration, then
processed nested control-flow with the alias env's post-state discarded. A
conditional `if (c) { delete f; }` (or reassignment) therefore never
invalidated the alias, so a trailing `f(x)` was statically resolved to a
direct `a(x)` call (success) instead of dispatching on the real, possibly
zeroed, pointer. solc lowers the delete-then-call to Panic(0x51).

Fix: decline the static alias whenever the alias name is reassigned or
deleted anywhere inside a nested block/if/loop/try later in the scope, keeping
`f` a genuine runtime pointer local so the call lowers to Stmt.internalCallPtr.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 04:21:16 -04:00

121 lines
4.6 KiB