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

Detect when position is not in known source #14801

Merged
merged 1 commit into from Apr 1, 2022

Conversation

nicolasstucki
Copy link
Contributor

If the position is outside of the known contents of the source we do not return any source.

Fixes #14785

@michelou
Copy link
Collaborator

@nicolasstucki On line 6 of test file tastyinspector/i14785.scala I would write split(File.pathSeparatorChar) instead of split(':').

@nicolasstucki nicolasstucki marked this pull request as ready for review March 29, 2022 06:59
If the position is outside of the known contents of the source we do not
return any source.
@anatoliykmetyuk anatoliykmetyuk merged commit 4a96ce7 into scala:main Apr 1, 2022
@anatoliykmetyuk anatoliykmetyuk deleted the fix-14785 branch April 1, 2022 10:23
@som-snytt
Copy link
Contributor

@nicolasstucki and on line 7, Windows wants the leading slash dropped, apparently.

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/actions-runner2/_work/dotty/dotty/compiler/../out/bootstrap/scala3-compiler-bootstrapped/scala-3.1.3-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-compiler_3-3.1.3-RC1-bin-SNAPSHOT.jar

as verified locally

scala> Paths.get(p)
java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/cygwin64/ho
me/andre/.sdkman/candidates/scala/2.13.4/lib/scala-compiler.jar
  at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182
)
  at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
  at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
  at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
  at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
  at java.base/java.nio.file.Path.of(Path.java:147)
  at java.base/java.nio.file.Paths.get(Paths.java:69)
  ... 32 elided

scala> Paths.get(p.drop(1))
val res26: java.nio.file.Path = C:\cygwin64\home\andre\.sdkman\candidates\scala\
2.13.4\lib\scala-compiler.jar

I'm glad I left cygwin installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Position#sourceCode throw StringIndexOutOfBoundsException
4 participants