Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

inline method arguments are executed separately on every access #24083

Closed as not planned
@soronpo

Description

I think below is not the expected behavior, but I'm not certain. Should the inline argument really be used as-is in every reference within the inline method?

Compiler version

v3.7.3

Minimized code

//> using scala 3.7.3
inline def foo(inline arg: Int): Unit =
 inline arg match
 case _ => println("examine1")
 inline arg match
 case _ => println("examine2")
def bar: Int = 
 println("hello")
 1
@main def test = foo(bar)

Output

hello
examine1
hello
examine2

Expectation

hello should be printed once.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /