question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import `export`ed function from another file lose default parameters

See original GitHub issue

Compiler version

3.1.2

Minimized code

from/E.scala

package from

object E {
  def toStr(b: Boolean = true) = {
    b.toString
  }
}

export E.toStr

main.scala

import from.toStr

@main def exportBug = {
  toStr()               //missing argument for parameter b of method toStr in package from: (b: Boolean): String
}

Output

compile error: missing argument for parameter b of method toStr in package from: (b: Boolean): String

Missing default parameters may be a compiler bug?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
pikinier20commented, Apr 26, 2022

I think we can reopen that as a bug in incremental compilation. It doesn’t work very well with exports.

Probably this issue is related to: https://github.com/lampepfl/dotty/issues/11841 .

0reactions
liewhitecommented, Apr 26, 2022

~The println surrounding the toStr() is crucial. You didn’t provide it in minimized example but right now I see it in your compiler log.~

~I agree, it fails on 3.1.2. Still, it doesn’t on newest nightly.~

EDIT: To be sure, I tested in on both scala-cli and sbt, and for the fact got sometimes compilation error on 3.1.2 but it might be related to incremental compilation. Making a clean build always succeeds on 3.1.2 and newest nightly.

Could you try to verify that?

Oh, it works with sbt clean compile, tks, i’ll close this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Call a function imported from another file - Stack Overflow
1 Answer 1. Sorted by: Reset to default. Highest score (default) ...
Read more >
Node.js Modules: Import and use Functions from Another File
To access the module functions, we have to export the functions and import them in the file we want to call the functions....
Read more >
Every Thing You Should Know About JavaScript Export
Default exports are useful to export only a single values. During the import, able to ommit the curly bares and use any name....
Read more >
export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >
Documentation - Modules - TypeScript
Default exports ​​ Each module can optionally export a default export. Default exports are marked with the keyword default ; and there can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found