scoverage / scalac-scoverage-plugin

Scoverage Scala Code Coverage Core Libs
https://github.com/scoverage
Apache License 2.0
425 stars 126 forks source link

ScalaJs: Found a dangling UndefinedParam at Position #477

Closed fdietze closed 2 years ago

fdietze commented 2 years ago

I just added the scoverage plugin to a scalajs project and it fails with the following error:

[error] /home/runner/work/outwatch/outwatch/util/src/main/scala/outwatch/util/WebSocket.scala:13:18: Found a dangling UndefinedParam at Position(...).
This is likely due to a bad interaction between a macro or a compiler plugin and the Scala.js compiler plugin.
If you hit this, please let us know.
[error] final case class WebSocket private(url: String) {
[error]                  ^
[error] one error found

https://github.com/outwatch/outwatch/runs/4499199813?check_suite_focus=true#step:7:219

PR: https://github.com/outwatch/outwatch/pull/553

mprevel commented 2 years ago

Hi @fdietze

I've just encountered the issue a few hours ago. It happens when a function (probably js native) has multiple parameters and some of them are not set. It should be valid especially when these parameters are optional in the js function, but it breaks the coverage.

For example : JSON.parse("{}") should be valid but will fail. To make it work you'll have to provide the second parameter that is a function that transforms the value so you have to write JSON.parse("{}", (key, value) => value). another example : element.addEventListener("mouseup", someCallback) will not work without theuseCapture` parameter set.

Sometimes adding an extra parameter keeps the same behaviors, sometimes not. It may also have an impact on performance.

I hope this issue could be fixed since this is very common.

ckipp01 commented 2 years ago

There is a chance that this has been fixed with some recent changes like https://github.com/scoverage/scalac-scoverage-plugin/pull/466. Are you able to test this again with the latest version to see if your issue is fixed? I'll move this over to the main repo since they fix would actually be there.

fdietze commented 2 years ago

Looks like it's working now, thank you!