diff --git a/src/wren_io.c b/src/wren_io.c index c583b28b..a04ed032 100644 --- a/src/wren_io.c +++ b/src/wren_io.c @@ -120,11 +120,9 @@ static void ioRead(WrenVM* vm) char buffer[MAX_READ_LEN]; char* result = fgets(buffer, MAX_READ_LEN, stdin); - if (result == NULL) { - // TODO: handle error. + if (result != NULL) { + wrenReturnString(vm, buffer, (int)strlen(buffer)); } - - wrenReturnString(vm, buffer, (int)strlen(buffer)); } static void ioClock(WrenVM* vm) diff --git a/test/io/read_eof.wren b/test/io/read_eof.wren new file mode 100644 index 00000000..07fd65c1 --- /dev/null +++ b/test/io/read_eof.wren @@ -0,0 +1 @@ +IO.write(IO.read) // expect: null