0.7.5 predef.sc compilation error with `...}}\ndef anything . . . ` #453
Comments
Thanks for the report! |
@emanresusername would one solution be to convert the
|
…ode, rather than having it apply to both REPL and scripts. This was introduced as a REPL feature (to allow people to enter multiple statements in one REPL block) and is not useful in scripts. Furthermore, it causes problems such as #453 due to the way we're parsing out the `{}`s. Those problems do not exist in the REPL since they only arise when there are subsequent expressions/statements following the unwrapped `{}` code, which cannot happen in the REPL since after completing a top-level `{}` entering a newline will cause the block to be submitted immediately, preventing you from entering further statements
@lihaoyi yeah, so in my case i was using {{
// don't want any of the defs in the repl session
def current_branch = {
scala.util.Try {
((%%git('branch)).out.lines.filter(grep!("""\*""".r))).head.substring(2)
}.toOption
}
def hostname = {
(%%hostname).out.lines.head
}
def whoami = {
(%%whoami).out.lines.head
}
def date = {
(%%date("-Is")).out.lines.head.split("-").dropRight(1).mkString("-")
}
repl.prompt.bind(
Seq(
Option(s"$whoami@$hostname:${wd.toString}[$date]"),
current_branch.map(branch => {
s"<$branch>"
}),
Option("\nᕕ( ᐛ )ᕗ ")
).flatten.mkString
)
}} with just |
FWIW, just using Welcome to the Ammonite Repl 0.7.5
(Scala 2.11.8 Java 1.8.0_102)
haoyi-Ammonite@ %cat "foo.sc"
private[this] val x = 1
val y = x + 1
haoyi-Ammonite@ import $file.foo
import $file.$
haoyi-Ammonite@ foo.x
cmd2.sc:1: value x is not a member of object $file.foo
val res2 = foo.x
^
Compilation Failed
haoyi-Ammonite@ foo.y
res2: Int = 2 |
Fixed in version |
predef.sc
works fine in 0.7.4
in the mean time, i worked around just putting the
{{}}
stuff at the endThe text was updated successfully, but these errors were encountered: