Skip to content

"using file" with URL+query parameters is broken #3720

@JD557

Description

@JD557

Version(s)
1.8.1

Describe the bug

The new using file feature with URLs doesn't work when a query parameter is passed.

The request is correctly sent to the server, but Scala CLI fails to use the downloaded code.

To Reproduce

Assume the following server:

//> using dep com.lihaoyi::cask::0.10.2

object Codegen extends cask.MainRoutes:
  @cask.get("/Special.scala")
  def dynamicWithParam(prefix: Option[String] = None): String =
    println("GOT PREFIX: " + prefix)
    val _prefix = prefix.getOrElse("NONE")
    val op = s"def specialPrint(msg: String): Unit = println(\"prefix:\" + msg)"
    s"""|package special
        |object Ops:
        |  $op""".stripMargin

  initialize()

The following code works as expected:

//> using file "http://localhost:8080/Special.scala"

import special.Ops.*

object Crazy:
  @main def run: Unit = specialPrint("bar")

But, when a query parameter is added to the using clause, it fails:

//> using file "http://localhost:8080/Special.scala?prefix=foo"

import special.Ops.*

object Crazy:
  @main def run: Unit = specialPrint("bar")

Fails with:

[error] value Ops is not a member of special
[error] import special.Ops.*

Even though the server logs the request correctly.

Expected behaviour

Both cases should compile and run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing featureSomething should have been implemented, but wasn't.spreeusing directivesIssues tied with using directives.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions