Skip to content

typer error when passing Nothing for function parameter of inline def #9786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
darichey opened this issue Sep 13, 2020 · 3 comments
Closed

Comments

@darichey
Copy link

Minimized code

inline def foo(f: () => Unit) = f()
def bar() = foo(???)

Output

[error] 1 |inline def foo(f: () => Unit) = f()
[error]   |                                ^^^
[error]   |   undefined: {
[error]   |     f$proxy1
[error]   |   }.apply # 25695: TermRef(TermRef(NoPrefix,val f$proxy1),apply) at typer
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

Expectation

The code should compile.

@darichey
Copy link
Author

darichey commented Sep 13, 2020

I ran into this when I mistakenly invoked this function:

inline def unless(b: Boolean)(f: () => Unit) =
  if (!b) f()

like this:

def baz(): Int = {
  unless(true) { return 5 }
  return 6
}

Of course, the f parameter should be by-name instead.

@smarter
Copy link
Member

smarter commented Sep 13, 2020

I think this could be tracked under the existing #8612 /cc @nicolasstucki

@nicolasstucki
Copy link
Contributor

It is the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants