oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.84k stars 156 forks source link

segfault on MacOS - maybe related to case statement #2037

Open dontlaugh opened 3 months ago

dontlaugh commented 3 months ago

This is on my work MacOS, an arm machine. The output of uname -a:

Darwin P0KD4MVQG4 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64

This is oils-for-unix version 0.22.0 compiled from source.

Here is a script that segfaults.

#!/usr/bin/env ysh

var WEIGHT = ${1:-}
case (WEIGHT) {
  "-" { echo "got nothing" }
  (else) { echo $WEIGHT 
}

The missing } (closing curly brace) triggers it, as far as I can tell.

andychu commented 3 months ago

I reproduced this, thank you!

andychu commented 3 months ago

I just pushed a fix for this -- it was related to not handling EOF in the lookahead we do to parse case

Thanks for the report!