-
Notifications
You must be signed in to change notification settings - Fork 1.1k
support in scalac for ignoring hash-bang line in script files #10858
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
Comments
we could look at using the ScriptSourceFile https://github.com/lampepfl/dotty/blob/33b710a40ca3a154a5f0e7788f91c4ca07085531/compiler/src/dotty/tools/dotc/util/SourceFile.scala#L21 |
I'd love to see this addressed. The same support in Scala 2 has always been really handy. |
Note that once sbt/sbt#6080 is addressed, it should become possible to use sbt's There's also Ammonite's scripting support; work on Scala 3 support is in progress com-lihaoyi/Ammonite#1135 |
Although Scala 2 provides scripting support, the exact above experiment with $ scalac jsrc/s3new.sc
\jsrc\s3new.sc:1: error: expected class or object definition
#!/usr/bin/env scala3.sh
^
1 error In other words, Scala 2 scripting is supported via It seems that in Scala 3, it's intended that It would be convenient if there were support for what python does: the bytecode generated by the compile step is stored in a .pyc or .pyo file, and the compile step is avoided except when the source file is newer than the compiled bytecode. The optional-compile approach requires a compile step (ideally ignoring hash-bang) with OPTIONAL execution . Then, scripts could be compiled to self-contained .jar files, greatly reducing latency on subsequent script runs, by avoiding the compile step. The re-compile decision could occur in the launcher script. A natural format would be a jar file with both java -jar <scriptFileCompiled.jar> The runtime classpath would only need to be specified during the compile step, e.g., @ or otherwise. |
sbt 1.5.0-M1 has direct support for Scala 3, so sbt/sbt#6080 is no longer a blocker for I've also opened a sbt ticket on this, sbt/sbt#6274, since work in both repos may be required |
fixed since #11379 |
Uh oh!
There was an error while loading. Please reload this page.
The current SNAPSHOT reports a "Syntax Error" when compiling a script file with a hash-bang on the first line.
The scalac version tested is:
For example, with the following script file and compile command:
Script file
s3new.sc
:I noticed some references to
#!
in some source files, but am not yet familiar with the compiler, so it's not clear if this feature is already in the plan:Without this compiler feature, it becomes unavoidable to make filtered copies of script sources, with compiler error messages referring the the copy rather than the original source file.
The text was updated successfully, but these errors were encountered: