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
Adding an unused second function can change another function's runtime result #60
On with v0.12.0-600-g1b8686565, the presence of an unused second function in the same file can change the runtime result of another function.
In the prepared neutral repro tree:
cd /tmp/wbug
with run main.w
Current result:
panic: assertion failed
If fn test_clamp is deleted from /tmp/wbug/main.w and nothing else changes, test_add() passes and with run main.w exits 0.
So the observable behavior of test_add() depends on whether an unrelated unused function exists in the same compilation unit.
Expected behavior
Unused functions must not change the runtime behavior of a called function.
with run main.w should execute main, call test_add(), and exit successfully because the asserted result is correct.
Spec references
docs/with-specification.md:2558 (## 9. Functions and Expressions / ### 9.1 Functions): functions have ordinary call semantics; adding an unused sibling function must not change another function's result.
docs/with-specification.md:7370 (with run <file>): with run executes the file's program.
docs/with-specification.md:7650 (assert(condition: bool)): assert should only panic when the condition is actually false.
Repro tree
Prepared locally at:
/tmp/wbug/main.w
/tmp/wbug/lib/demo/core.w
/tmp/wbug/lib/demo/device.w
/tmp/wbug/lib/demo/errors.w
/tmp/wbug/lib/demo/ir.w
/tmp/wbug/lib/demo/ir_text.w
/tmp/wbug/lib/demo/memory.w
/tmp/wbug/lib/demo/program.w
/tmp/wbug/lib/demo/stream.w
/tmp/wbug/lib/demo/view.w
/tmp/wbug/lib/demo/cpu_interp.w
Minimal observed shape
main.w contains:
a helper compile_text_source(text: str) -> ProgramSource
fn test_add that parses/compiles a small add kernel and asserts the output is 9
fn test_clamp that does the same for a clamp kernel, but is never called
fn main: test_add()
The failure disappears if test_clamp is removed.
Commands
with version
cd /tmp/wbug
with check main.w
with run main.w
On my side:
with v0.12.0-600-g1b8686565
with check main.w says ok, but with run main.w panics.
Activity
Fix multiline match arm block parsing