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
with -n: a two-line snippet (let, then if) ignores the if's condition and prints every line #1238
Repro, installed compiler (main at be767c0 + #1237 branch build):
printf "x\ta\nx\tdocs\nx\tREADME.md\n" > in.txt
# two lines: let, then if — prints ALL three lines (wrong)
with -n 'let path = line.split("\t").get(1)
if path != "docs" and not path.ends_with(".md"): print(line)' < in.txt
# the same condition inline — prints only `x\ta` (right)
with -n 'if line.split("\t").get(1) != "docs" and not line.split("\t").get(1).ends_with(".md"): print(line)' < in.txt
# two lines, simpler condition — still prints all three (wrong)
with -n 'let path = line.split("\t").get(1)
if path != "docs": print(line)' < in.txt
Expected: a multi-line -n body is the per-line program, statements in order, line bound; the if filters. Actual: with a leading let, the following if … : print(line) prints unconditionally (or path is not the value of the let).
Found while checking the green-identity fix (#1237) by hand: the by-hand listing kept the docs and *.md entries the lanes had (correctly) dropped, and for a minute it looked like the implementations disagreed. §18.5b one-liners; a failing with -n is a product bug, never a license for sed/awk.
Duplicate of #962, with a stronger repro: the view is not merely zeroed, it is dangling.
fn main:
let line = "x\tdocs"
let path = line.split("\t").get(1) // view into the temporary Vec split() returned
print(f"{path != "docs"} {path == "docs"} {path.ends_with(".md")}") // true false false (all wrong)
let parts = line.split("\t")
let p2 = parts.get(1)
print(f"{p2 != "docs"} {p2 == "docs"}") // false true (right)
This is not a one-liner bug: with -n wraps the snippet correctly; the let in it binds a view into a statement temporary and safe code reads freed memory. Closing this in favour of #962, which names the fix (reject the binding under D27/§21.1).
Activity
ehartford commentedon Sep 20, 2026
Duplicate of #962, with a stronger repro: the view is not merely zeroed, it is dangling.
This is not a one-liner bug:
with -nwraps the snippet correctly; theletin it binds a view into a statement temporary and safe code reads freed memory. Closing this in favour of #962, which names the fix (reject the binding under D27/§21.1).A view into a statement temporary cannot be bound or returned (#962) (#…