tdenniston / bish

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.
MIT License
1.48k stars 36 forks source link

Unclear error message on syntax error. #70

Open akalsi87 opened 8 years ago

akalsi87 commented 8 years ago

The following snippet complains that newval is not defined, however it is.

def slice_lines(val, start) {
    nlines = numlines(val)
    if (nlines < 2) {
        println("Error1.")
        quit(0)
    }
    newval = ""
    for (curr in 1 .. nlines) {
        line = getline(val, curr)
#        if (curr >= start) {
            println("Got line: $line")
#            if (curr != start) {
#                newval = printf("$newval\n$chompline")
#            }
        }
    }
    return newval
}

Error:

Bish error: Undefined variable "newval"
Abort
akalsi87 commented 8 years ago

The real error here is:

#            }
        } <---- this line should be commented
    }
    return newval