elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.72k stars 303 forks source link

Defer inside a for loop causes early exit #1849

Open xiaq opened 1 month ago

xiaq commented 1 month ago

What happened, and what did you expect to happen?

This is unexpected:

for v [a b c] {
  defer { put defered }
  put $v
}
▶ a
▶ defered

Output of "elvish -version"

0.22.0-dev.0.20241002144851-c20fac4126aa-dirty

Code of Conduct