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

Semicolon is not inferred after a XML node sequence literal #9027

Closed
scabug opened this issue Dec 3, 2014 · 8 comments
Closed

Semicolon is not inferred after a XML node sequence literal #9027

scabug opened this issue Dec 3, 2014 · 8 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Dec 3, 2014

scalac reports error in the following code;

object Obj {
  val s1 = <a/><b/>
  println("hi")
}

value println is not a member of scala.xml.NodeBuffer possible cause: maybe a semicolon is missing before `value println'?

When <a/></b> is either replaced with <a/> alone or enclosed in parentheses or curly braces, code is compiled without error. Entering the semicolon as suggested also allows compilation to proceed.

@scabug
Copy link
Author

scabug commented Dec 3, 2014

Imported From: https://issues.scala-lang.org/browse/SI-9027?orig=1
Reporter: Rafał Krzewski (rkrzewski)
Affected Versions: 2.10.4, 2.11.4
Other Milestones: 2.11.5

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@retronym said:
This is intentional (if not ideal), as XML syntax allows newlines within NodeSeq literals.

:paste
// Entering paste mode (ctrl-D to finish)

<a/>
<b/>
<c/>


// Exiting paste mode, now interpreting.

res0: scala.xml.NodeBuffer = ArrayBuffer(<a/>, <b/>, <c/>)

@scabug
Copy link
Author

scabug commented Dec 4, 2014

@som-snytt said:
But it should not consume whitespace if it looks ahead and detects the end of XML mode.

scala/scala#4185

@scabug
Copy link
Author

scabug commented Dec 4, 2014

@som-snytt said:
This issue sounded very familiar FSR. Why did I use the same example?

scala> :pa
// Entering paste mode (ctrl-D to finish)

object X {
  val s = <a/>
          <b/>
          <c/>

  println("ack")
}

// Exiting paste mode, now interpreting.

defined object X

scala> X
ack
res0: X.type = X$@17f62e33

scala> object X {
     |   val s = <a/><b/>                                           <- spaces are harmless?
     |   println("ack")
     | }
defined object X

scala> X
ack
res1: X.type = X$@3da05287

@scabug
Copy link
Author

scabug commented Dec 4, 2014

@som-snytt said:
Happy to close again if I broke something.

@scabug
Copy link
Author

scabug commented Dec 4, 2014

Andrzej Jozwik (ajozwik) said (edited on Dec 4, 2014 8:12:48 AM UTC):
The sbt from version 0.13.7 uses scala compiler to parse the whole file. The problem is, that if you split the file statement by statement and send to the compiler - all will be OK. If you send whole file - you will receive the compilation error.
See:
sbt/sbt#1606

The test from repl:

scala> :pa
// Entering paste mode (ctrl-D to finish)

object A {

val a = <a/>

val b = <c/><d/>
}

// Exiting paste mode, now interpreting.

defined object A

And:

scala> :pa
// Entering paste mode (ctrl-D to finish)

object A {

val a = <a/><c/>

val b = <b/>
}

// Exiting paste mode, now interpreting.

<console>:5: error: ';' expected but 'val' found.
val b = <b/>

@scabug
Copy link
Author

scabug commented Dec 4, 2014

@gkossakowski said:
Fixed by scala/scala#4185

@scabug scabug closed this as completed Dec 4, 2014
@scabug
Copy link
Author

scabug commented Dec 8, 2014

@gkossakowski said:
Backported to 2.10.x in: scala/scala#4186

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

No branches or pull requests

2 participants