Closed philwalk closed 3 months ago
TBH I'm not sure if this is the correct behavior for this. I think it's reasonable for it to fail and downstream to handle it, v.s. arbitrarily returning empty strings.
There are tons of cases where empty strings are not what you want either, and they have a tendency to propagate far beyond the point of creation before misbehaving in complicated ways. In comparison, the exception immediately tells you what's going on and you can remediate it at the failure site
TBH I'm not sure if this is the correct behavior for this. I think it's reasonable for it to fail and downstream to handle it, v.s. arbitrarily returning empty strings.
I don't disagree with your reasoning. A concern is that throwing of an exception makes it unsafe to call .baseName
on any os.Path
that might be === os.root
. Empty string is a reasonable way to represent that a path has no segments, implying that it's os.root
. This is similar to the way that dirname /
returns /
rather than an error message.
On the other hand, this change might cause problems with existing client code, so perhaps this needs to be handled the way you suggest, thanks for the feedback.
This addresses the problems described by #276 It provides a fix for https://github.com/VirtusLab/scala-cli/issues/2954 It makes
os.root.last
the empty string rather than throwingLastOnEmptyPath
. Then, it definesos.root.baseName
ass"$driveRoot/"
, rather than throwing an Exception.