scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Broken compilation when script name equals to library name

Open road21 opened this issue 1 year ago • 1 comments

Version(s) 1.6.1, 1.7.1

Describe the bug In worksheet mode filename affects compilation.

To Reproduce

  1. Create file zio.sc with code:
//> using dep "dev.zio::zio:2.1.16"

import zio.ZIO
  1. Run: scala-cli zio.sc

Got:

[error] ./zio.sc:4:12
[error] value ZIO is not a member of zio$_
[error] import zio.ZIO
[error]            ^^^

Expected behaviour

No compiler errors. In non-worksheet mode (if filename is zio.scala) the behavior is as expected.

road21 avatar Mar 27 '25 13:03 road21

We will likely not be able to fix this use case fully, as it'd break other stuff. For a full explanation, see the discussion under @yadavan88's draft PR:

  • https://github.com/VirtusLab/scala-cli/pull/3647#issuecomment-2838015070

However, the window is open for adding workarounds/doing UX improvements. I will leave the issue open for now.

Gedochao avatar Apr 29 '25 09:04 Gedochao