Skip to content

Regression in parsing XML symbols used in old if-else syntax #16459

Closed
@WojciechMazur

Description

@WojciechMazur

Compiler version

3.2.1

Minimized code

//> using lib "org.scala-lang.modules::scala-xml:2.1.0"

@main def Test() = {
  val elem = if(true) {
    <script type="text/javascript">
      'location.reload()'
      'foo bar'
    </script>
  } else <div>empty</div>

  println(elem)
}

Replacing parentheses with new if/then syntax allows to compile this code

// works with both `if true then ...` and `if true then { ...` 
//> using lib "org.scala-lang.modules::scala-xml:2.1.0"

@main def Test() = {
  val elem = if true then {
    <script type="text/javascript">
      'location.reload()'
      'foo bar'
    </script>
  } else <div>empty</div>

  println(elem)
}

Output

[error] ./test.sc:7:25: unclosed character literal
[error]       'location.reload()'
[error]      
[error] ./test.sc:8:15: unclosed character literal
[error]       'foo bar'
[error]     

Expectation

Should compile with output:

<script type="text/javascript">
      'location.reload()'
    </script>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions