Fixes error mesaging for read-bytes

This commit is contained in:
sloum 2022-07-08 19:48:02 -07:00
parent a740318116
commit ae321a2a96

8
lib.go
View File

@ -1522,12 +1522,12 @@ var stdLibrary = vars{
return exception("'read-all-lines' has not been implemented for this object type")
}
},
"read-byte": func(a ...expression) expression {
"read-bytes": func(a ...expression) expression {
if len(a) == 0 {
reader := bufio.NewReader(os.Stdin)
b, err := reader.ReadByte()
if err != nil {
return exception("'read-byte' could not read from stdin")
return exception("'read-bytes' could not read from stdin")
}
return number(b)
} else {
@ -1543,12 +1543,12 @@ var stdLibrary = vars{
if len(a) > 1 {
c, ok := a[1].(number)
if !ok {
return exception("'read-byte' expected its optional second argument to be a number")
return exception("'read-bytes' expected its optional second argument to be a number")
}
count = int(c)
}
if count < 1 {
return exception("'read-byte' expected its second argument to be a number greater than 0")
return exception("'read-bytes' expected its second argument to be a number greater than 0")
}
b := make([]byte, count)