Skip to content
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

Regression in yakivy/jam - unknown value error in separate compilation runs #22593

Open
jchyb opened this issue Feb 12, 2025 · 3 comments
Open
Assignees
Labels
area:inline area:metaprogramming:quotes Issues related to quotes and splices area:typer itype:bug regression This worked in a previous version but doesn't anymore

Comments

@jchyb
Copy link
Contributor

jchyb commented Feb 12, 2025

https://github.com/VirtusLab/community-build3/actions/runs/13209505213/job/36881078477

Compiler version

Working: 3.6.3
Broken: 3.6.4-RC1

Minimized code

Similarly to #22581, the files have to be compiled in separate compilation runs for the regression to show. Let's use scala-cli for simplicity.
main.scala

import scala.quoted.*

package jam {
    trait JamCoreDsl {
        implicit inline def defaultJamConfig: this.JamConfig =
            new JamConfig(brewRecRegex = ".*")
        class JamConfig(val brewRecRegex: String)
        inline def brew(implicit inline config: JamConfig): Unit = ${ brewImpl() }
    }
    private object internal extends JamCoreDsl
    export internal._

    def brewImpl(using q: Quotes)(): Expr[Unit] = {
        findSelf
        '{()}
    }

    private def findSelf(using q: Quotes): Unit = {
        import q.reflect.*
        def rec(s: Symbol): Option[Symbol] = s.maybeOwner match {
            case o if o.isNoSymbol => None
            case o if o.isClassDef => Option(o)
            case o => rec(o)
        }
        rec(Symbol.spliceOwner)
    }
}

main.test.scala

object CoreSpec  {
  jam.brew
}

scala-cli test main.scala main.test.scala -S 3.6.4-RC1

Output

[error] -- [E007] Type Mismatch Error: /Users/jchyb/workspace/community-build3/repo/core/src-3/jam/package.scala:2:12 
[error] 2 |    jam.brew
[error]   |            ^
[error]   |            Found:    jam.internal.JamConfig
[error]   |            Required: ?1.JamConfig
[error]   |
[error]   |            where:    ?1 is an unknown value of type object jam.internal
[error]   |-----------------------------------------------------------------------------
[error]   | Explanation (enabled by `-explain`)
[error]   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]   |
[error]   | Tree: {
[error]   |   val JamCoreDsl_this: jam.internal.type = jam.internal
[error]   |   new JamCoreDsl_this.JamConfig(brewRecRegex = ".*"):JamCoreDsl_this.JamConfig
[error]   | }
[error]   | I tried to show that
[error]   |   jam.internal.JamConfig
[error]   | conforms to
[error]   |   ?1.JamConfig
[error]   | but none of the attempts shown below succeeded:
[error]   |
[error]   |   ==> jam.internal.JamConfig  <:  ?1.JamConfig
[error]   |     ==> jam.internal.type  <:  (?1 : object jam.internal)
[error]   |       ==> object jam.internal  <:  (?1 : object jam.internal)  = false
[error]   |
[error]   | The tests were made under the empty constraint
[error]    -----------------------------------------------------------------------------

Expectation

No error. Although, similarly to #22581, if both files are put into the same compilation run, another error is shown (also on earlier compiler versions):

[error] -- [E007] Type Mismatch Error: /Users/jchyb/workspace/community-build3/repo/core/src-3/jam/package.scala:2:12 
[error] 2 |    jam.brew
[error]   |            ^
[error]   |            Found:    jam.internal.JamConfig
[error]   |            Required: Nothing
[error]   |-----------------------------------------------------------------------------
[error]   | Explanation (enabled by `-explain`)
[error]   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]   |
[error]   | Tree: {
[error]   |   val JamCoreDsl_this: jam.internal.type = jam.internal
[error]   |   new JamCoreDsl_this.JamConfig(brewRecRegex = ".*"):JamCoreDsl_this.JamConfig
[error]   | }
[error]   | I tried to show that
[error]   |   jam.internal.JamConfig
[error]   | conforms to
[error]   |   Nothing
[error]   | but none of the attempts shown below succeeded:
[error]   |
[error]   |   ==> jam.internal.JamConfig  <:  Nothing  = false
[error]   |
[error]   | The tests were made under the empty constraint
[error]    -----------------------------------------------------------------------------
@jchyb jchyb added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 12, 2025
@Gedochao Gedochao added area:typer regression This worked in a previous version but doesn't anymore stat:needs bisection Need to use nightly builds and git bisect to find out the commit where this issue was introduced area:inline area:metaprogramming:quotes Issues related to quotes and splices and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 13, 2025
@jchyb
Copy link
Contributor Author

jchyb commented Feb 17, 2025

Bisect script points to 26ecda5 as the first "regressive" commit, which I think makes sense - those two files, if compiled together in the same compilation run, would always error (as it would notice these things while in typer), and in two separate runs, it would try to make the same check in pickler. It could be argued that the behavior now is more consistent.

@Gedochao Gedochao removed the stat:needs bisection Need to use nightly builds and git bisect to find out the commit where this issue was introduced label Feb 18, 2025
@Gedochao
Copy link
Contributor

Bisect script points to 26ecda5 as the first "regressive" commit, which I think makes sense - those two files, if compiled together in the same compilation run, would always error (as it would notice these things while in typer), and in two separate runs, it would try to make the same check in pickler. It could be argued that the behavior now is more consistent.

@dwijnand thoughts?

The bisect also points to the same commit as #22596 and #22585, btw.

@jchyb
Copy link
Contributor Author

jchyb commented Feb 18, 2025

#22596 and #22585 do not have that "always error in one compilation run, but only now error in when split into two" quirk (so they seem more like actual regressions), however #22581 does (but I need to run the bisect script to confirm that it is indeed the same commit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:inline area:metaprogramming:quotes Issues related to quotes and splices area:typer itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

No branches or pull requests

3 participants