Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading a non-existent file on JS on Windows crashes #702

Open
jiribenes opened this issue Nov 20, 2024 · 1 comment
Open

Reading a non-existent file on JS on Windows crashes #702

jiribenes opened this issue Nov 20, 2024 · 1 comment
Labels
bug Something isn't working windows

Comments

@jiribenes
Copy link
Contributor

jiribenes commented Nov 20, 2024

Confirmed repro:

import io
import io/error
import io/filesystem
import exception

def peek(filename: String): Option[Char] / Files = {
  val contents = do readFile(filename)
  if (contents.length == 0) None()
  else Some(contents.unsafeCharAt(0))
}

def run(filename: String) = {
  with default[IOError, String]{ "File not found" };
  with filesystem;
  peek(filename) match {
    case None() => "Empty file"
    case Some(c) => "The first letter is: " ++ show(c)
  }
}

def main() = println(run("ThisFileDoesNotExist"))

works on my machine (M1), printing File not found.
But on Windows, it seems to crash with:

Screenshot 2024-11-20 at 11 53 42

Here's a trace of how I think this might have happened:

return errnoMap[-errno] || -1; // Default to -1 for unknown error names

case _ => panic("Not a valid error code: " ++ show(number))

@jiribenes jiribenes added the bug Something isn't working label Nov 20, 2024
@marzipankaiser
Copy link
Contributor

marzipankaiser commented Nov 26, 2024

Can reproduce on Windows/ARM in Parallels. However, coursier doesn't work there IIUC ( coursier/coursier#2175 ), so I don't really have a dev environment there... (in particular, no sbt)Just noticed: This is stdlib, so I could try and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows
Projects
None yet
Development

No branches or pull requests

3 participants