wryun / es-shell

es: a shell with higher-order functions
http://wryun.github.io/es-shell/
Other
307 stars 25 forks source link

Corner case on glomming with `%closure` #57

Closed jpco closed 9 months ago

jpco commented 1 year ago

See the following command:

; let (n = '%closure (x = y) echo $x') {$n}
y y

The correct behavior (and the behavior that comes from variations on the command, like putting {} around the echo $x, is to only print one y.

Digging around with gdb I see the bogus extra y gets added in eval.c:418 (list = append(list, list->next);). Commenting out that line fixes the issue, and strangely seems to be a no-op in most other cases -- trip.es passes, and I can do at least some basic navigating in an interactive shell. It looks like list->next at this point in the code is typically null.

Is it reasonable to delete the line? Can anyone find something that would break?