Dotty: Replace hardcoded uses of ":" by File.pathSeparator

Created on 24 Aug 2018  路  6Comments  路  Source: lampepfl/dotty

":" is used in various places in the codebase, this is wrong (it doesn't work on Windows) and should be replaced by File.pathSeparator

novice help wanted bug

Most helpful comment

/ is usually OK on Windows in Java, because the abstractions will convert them. Except of course if you get a file name from the file system the look for /es in it. If you do that you should first normalize.

All 6 comments

Regarding Windows, I noticed we use /, is that OK? Shouldn't we use File.separator?

/ is usually OK on Windows in Java, because the abstractions will convert them. Except of course if you get a file name from the file system the look for /es in it. If you do that you should first normalize.

Some progress in #5085 by @martijnhoekstra, but they suggest we shouldn鈥檛 be closing this yet.

@Blaisorblade I would suggest closing this for now -- I can't promise there are absolutely no hardcoded strings containing : remaining, though I reviewed all strings ":" and chars ':', there may still be "foo:bar"'s that are harder to find -- but this issue isn't actionable anymore I think

in scala, the platform-dependency issues tend to be

  • Classpath separators (like here)
  • checking for path separators '/' (though using '/' is fine)
  • line endings. the difference between \r\n and \n represents a semantic difference if the line end is part of a multiline string, and println will emit \r\n on windows. Adding insult to injury, if windows users have git autocrlf set (out of dubious recommendations of compatibility) they may have crlf in their local repos where there is no such \r present in the original source.

Ironically, many issues occur when one part of some system attempts to do platform compatibility for unneeded reasons (java println, git autoclrf, auto-conversion of /), and other parts don't, and then suddenly you have situations where you're checking for \r\n on windows while there is a \n which is working just fine, leading to errors or test failures.

Closing on @martijnhoekstra鈥檚 recommendation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

letalvoj picture letalvoj  路  27Comments

odersky picture odersky  路  28Comments

odersky picture odersky  路  114Comments

smarter picture smarter  路  40Comments

felixmulder picture felixmulder  路  120Comments