Skip to content

Support shebang in .scala files with the Scala 3 dialect #3267

@rmgk

Description

@rmgk

Configuration (required)

version = 3.5.8
runner.dialect = scala3

Steps

Given code like this:

#!/usr/bin/env scala

@main def run() = println("hello world!")

Problem

Scalafmt formats code like this:

.../main.scala:1: error: [dialect scala3] illegal start of definition identifier
#!/usr/bin/env scala
^

Expectation

The file is legal scala3 (can be run with scala main.scala and compiled with scalac main.scala), and should be formatted while ignoring the first line.

Notes

There seems to be supported for ammonite scripts, or rather anything with a .sc file ending

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions