Skip to content

varargs in main causes errors #1391

@tcmulcahy

Description

@tcmulcahy

I'm running Ammonite on Mac Ventura 13.4, Ammonite version:

$ amm --version
Ammonite REPL & Script-Runner, 2.5.11

Ammonite was installed via homebrew.

I'm able to use Ammonite just fine, until I try to use varargs in my main function (like documented here: https://ammonite.io/#ScriptArguments). Here's my minimal repro

$ cat /tmp/test
#!/usr/bin/env amm
// vi: filetype=scala

@main
def entrypoint(args: String*) = {
}

And here's the errors I get:

$ /tmp/test
Compiling /tmp/test
exception caught when loading class $: java.lang.AssertionError: assertion failed
-- Warning: /tmp/test:3:24 -----------------------------------------------------
3 |package $file.^.^.^.^.^.^.tmp
  |                        ^
  |The package name `^` will be encoded on the classpath, and can lead to undefined behaviour.
-- Warning: /tmp/test:3:22 -----------------------------------------------------
3 |package $file.^.^.^.^.^.^.tmp
  |                      ^
  |The package name `^` will be encoded on the classpath, and can lead to undefined behaviour.
-- Warning: /tmp/test:3:20 -----------------------------------------------------
3 |package $file.^.^.^.^.^.^.tmp
  |                    ^
  |The package name `^` will be encoded on the classpath, and can lead to undefined behaviour.
-- Warning: /tmp/test:3:18 -----------------------------------------------------
3 |package $file.^.^.^.^.^.^.tmp
  |                  ^
  |The package name `^` will be encoded on the classpath, and can lead to undefined behaviour.
-- Warning: /tmp/test:3:16 -----------------------------------------------------
3 |package $file.^.^.^.^.^.^.tmp
  |                ^
  |The package name `^` will be encoded on the classpath, and can lead to undefined behaviour.
-- Warning: /tmp/test:3:14 -----------------------------------------------------
3 |package $file.^.^.^.^.^.^.tmp
  |              ^
  |The package name `^` will be encoded on the classpath, and can lead to undefined behaviour.
-- [E007] Type Mismatch Error: /tmp/test:58:60 ---------------------------------
 58 |  def apply() = mainargs.ParserForMethods[$routesOuter.type]($routesOuter)
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                Found:    Seq[String]
    |                Required: String
    |---------------------------------------------------------------------------
    |Inline stack trace
    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |This location contains code that was inlined from Macros.scala:120
    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |This location contains code that was inlined from Macros.scala:120
     ---------------------------------------------------------------------------
    |
    | longer explanation available when compiling with `-explain`
Compilation Failed

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