Skip to content

Xprint doesn't show literal types correctly #22349

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

Closed
hamzaremmal opened this issue Jan 12, 2025 · 1 comment · Fixed by #22351
Closed

Xprint doesn't show literal types correctly #22349

hamzaremmal opened this issue Jan 12, 2025 · 1 comment · Fixed by #22351
Assignees
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Milestone

Comments

@hamzaremmal
Copy link
Member

hamzaremmal commented Jan 12, 2025

Compiler version

5176f9f

Minimized code

Printing the tree with -Xprint:parser returns code that is not valid scala 3 code

inline val _: true = true   // boolean literal
inline val _: "abc" = "abc" // string literal
inline val _: 'c' = 'c'     // character literal
inline val _: 1.2f = 1.2f   // floating point literal
inline val _: 1.2d = 1.2d   // double number literal

Output

[[syntax trees at end of                    parser]] // playground.scala
package <empty> {
  inline val _: true.type = true
  inline val _: "abc".type = "abc"
  inline val _: 'c'.type = 'c'
  inline val _: 1.2f.type = 1.2f
  inline val _: 1.2d.type = 1.2d
}

Expectation

[[syntax trees at end of                    parser]] // playground.scala
package <empty> {
  inline val _: true = true
  inline val _: "abc" = "abc"
  inline val _: 'c' = 'c'
  inline val _: 1.2f = 1.2f
  inline val _: 1.2d = 1.2d
}
@hamzaremmal hamzaremmal added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 12, 2025
@hamzaremmal hamzaremmal self-assigned this Jan 12, 2025
@som-snytt
Copy link
Contributor

-Vprint. (-Xprint is an alias for backward compatibility.)

Another anomaly, if it is one, is that literals are printed with color under -Yplain-printer.

//> using options -Vprint:parser -Yplain-printer
@main def test() = println:
  "hello, world!"

-color:never is respected, but should it be necessary when printing plainly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants