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
enumerate() over a List[CeremonyEdit] fails to instantiate: std/traits.w:647 None => None return type mismatch, while the same loop over a small list compiles #3077
that is Enumerated.next (impl[T, I: Iter[T]] Iter[(i64, T)] for Enumerated[T, I]) instantiated for edits.enumerate() with edits: List[CeremonyEdit] (type CeremonyEdit { path: str, start: i32, end: i32, replacement: str, what: str }). The loop that triggered it, in run_ceremony_fix (the other two loops in the same function had the same shape):
let err_path = "out/fix-ceremony-check.err"
while true:
let fin = run_to_files([with_str_clone_ref(check_with), "check", with_str_clone_ref(entry)], out_path, err_path, 0)
if fin.code == 0: break
var progress = false
for line in (with_fs_read_file(err_path)).split("\n"):
if not line.contains("--> "): continue
let loc = line.split("--> ")[1].split(":")
if loc.len() < 2: continue
let epath = loc[0]
let eline: i32 = loc[1].parse() ?? 0
// The refusal names a use; the rewrite that caused it is on that
// line or the nearest rewritten line above it.
var best = -1
for (ei, e) in edits.enumerate():
if dropped[ei] or e.path != epath: continue
if edit_lines[ei] <= eline + 1 and edit_lines[ei] >= eline - 12 and (best < 0 or edit_lines[ei] > edit_lines[best]): best = ei
if best < 0: continue
for (ei, e) in edits.enumerate():
if not dropped[ei] and e.path == epath and edit_lines[ei] == edit_lines[best]:
dropped[ei] = true
progress = true
if not progress:
The same shape as a small program compiles and runs:
type E { path: str, start: i32, what: str }
fn main:
let edits = [E { path: "a", start: 1, what: "x" }, E { path: "b", start: 2, what: "y" }]
let lines = [e.start * 10 for e in edits]
let dropped = [false for e in edits]
dropped[1] = true
var kept = 0
for (ei, e) in edits.enumerate():
if dropped[ei]:
kept = kept + 1
print(f"{e.path}:{lines[ei]}: {e.what}")
print(f"{kept}")
So the failure depends on something in the compiler's own instantiation context (a (i64, T) tuple instance already present with another T, or T bound as a view of CeremonyEdit). The three loops were rewritten as index loops to land the tool; the branch's history holds the failing version. Route: WITH_TRACE_INST=1 on with check src/main.w with the enumerate loop restored, then with reduce with the std error as the predicate.
Activity
#3077: a body checked on demand starts in value position, and a retur…
#3088: an undemanded bare variant name resolves by scope, not by the …