Skip to content

Conversation

@som-snytt
Copy link
Contributor

Fixes #24375

The original name can be recovered for messages.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks workable to me. The test failures seem to come from this part in Message.scala:

    override def ParamRefNameString(param: ParamRef): String =
      seen.record(super.ParamRefNameString(param), param.isInstanceOf[TypeParamRef], param)

Maybe we can try to just turn off seen.record here, i.e. drop the whole def? I am not sure more explanations of parameter names help. But one has to try it out and look at the changes.

@som-snytt som-snytt force-pushed the issue/24375-context-function-param-names branch from 73533af to dab9edb Compare November 12, 2025 10:36
@som-snytt
Copy link
Contributor Author

Just a stop-gap update. I will revisit the parameter disambiguation.

Now it is aware that the written l and the inferred lcontextual$1 are not the same. Or maybe just let it ignore the difference.

def withFile[T](op: (l: caps.Capability) ?-> (f: File^{l}) => T): T =
  op(using caps.cap)(new File)

def test =
  withFile: f =>       // error with level checking, was OK under both schemes before
    val o = Service()
    o.file = f
    o.log

@odersky
Copy link
Contributor

odersky commented Nov 12, 2025

I think @Sporarum's comment on the issue makes sense.

protected def ParamRefNameString(param: ParamRef): String =
ParamRefNameString(param.binder.paramNames(param.paramNum))
val name = param.binder.paramNames(param.paramNum)
ParamRefNameString:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering @Sporarum's comment on the issue :
#24375 (comment)

Maybe we should work on the toString function for ContectFunctionParamNames instead of intervening here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context function parameter name leaks into scope

2 participants