-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Phase assembly is circumspect about loose constraints #10856
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
base: 2.13.x
Are you sure you want to change the base?
Conversation
a42d995
to
ecdf2dd
Compare
ecdf2dd
to
a6b1d7d
Compare
log(s"newSettings: allArgs = $allArgs") | ||
val (success, residual) = s.processArguments(allArgs, processAll = false) | ||
assert(success && residual.isEmpty, s"Bad settings [${args.mkString(",")}], residual [${residual.mkString(",")}]") | ||
} | ||
// scaladoc has custom settings | ||
def newSettings(): Settings = new Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this newSettingsBase()
or something like that? With the same name as the overload I would expect this method to be an alias for newSettings(args)
with some default args
; not a base method that newSettings(args)
must call to create its instance of Settings
.
3b8ec27
to
53b6723
Compare
I'll take another look when my eyes are fresh, but some notes:
|
c0e8f7a
to
335e949
Compare
but |
crashes 2.13.14 creating the dot file
Realized I don't need N plugins but one plugin with N components to test the permutations. In Knuth, "boolean basics" says here's a table of operations, there are 16 of them. I was like what? so in addition to not assuming I know anything, I assume I know less than I thought I did. Edit: well, this PR also throws for reporting.
for
where I think we don't want to ignore a before constraint that correctly names a phase but the constraint can't be satisfied. (The original ticket 8755 mentions this behavior of runsRightAfter.) Naturally it also detects the other case
I think I already knew 2.13.14 scalac fails on these obvious constraints.
So we don't want to remain bug-compatible, but merely convenience-compatible for Scaladoc. Worth adding that on linked ticket 7905 ten years ago, I'd already noticed that generating the phase graph file throws. The OG also complains that before constraint is not sufficient. This PR accepts C7 with no after constraint (only before terminal) because it is reachable through C8. I'm about to change that and preserve that one bit of buggy behavior, because Lukas said to, and because it is easy to describe: a runs-after constraint is required. TODO that's incorrect, 2.13.14 has the same behavior; scaladoc says
|
I feel bad even suggesting this, but perhaps it would be better to revert the original PR entirely, in order not to be under time pressure, then try to land a revised version in 2.13.16. |
@SethTisue I see your point, but it's just shaking out a few edge cases. That's not going to change by waiting. I'll add the comprehensive test for review of all possible behaviors. However, it does belie the current practice that "it doesn't matter if we merge PRs because nothing will get tested until the week before the release." "Cramming" is what makes Scala a so-called "academic language", I just realized. |
I am the last to understand that scala-js exposes different components for scaladoc:
so there is no mysterious convenience in trimming them. I haven't refreshed my memory about backend phases yet. |
It's a good counterargument to observe that the only additional plugins, not in the community build, that are likely to get tested with this, and only at release time, are Scala.js, Scala Native, and my own Fortify plugin. |
I'm just going to finish Jane the Virgin before I push another commit, but I realize Scala 2 is basically EOL so you have your priorities, it's really no skin off my nose. Edit: that was followed by a Charmed marathon. |
Huh. I had completely forgotten about that. Sorry for leading the instigation in the wrong direction. 🙁 |
Celebrating 11 yrs since scala-js plugin. |
addConstraint(p.phaseName, before, Follows) | ||
constrained = true | ||
} | ||
// if it doesn't follow a phase in the run, replace this component with a no-op that follows start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are two phases where p2 runsAfter p1
and p1 runsAfter typo
, then only p1
is replaced by a noop.
Here's another approach, I'll clean it up and adjust / add tests: https://github.com/scala/scala/compare/2.13.x...lrytz:scala:pr10856?expand=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the noop to a list of names to filter out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that a change that you didn't push yet?
|
78d1dc5
to
1f5df3f
Compare
66c8adc
to
40b45a6
Compare
Threw in a I did not yet add the test for "two components are dropped". I intended to comment in the minor refactor in PhaseAssembly.traverse that filtering for I could polish more, as there are a few spots where I can't see my face. |
private object TestComponent extends PluginComponent { | ||
val global: Ploogin.this.global.type = Ploogin.this.global | ||
override val runsBefore = List("jvm") | ||
val runsAfter = List("typer", "refchecks") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, #10856 drops the phase because one of the runsAfter
constraints is invalid. I think either way is fine here.
2.13.14 scaladoc drops the "refchecks" constraint and runs the phase after "typer".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I should have documented it: if runsAfter means "depends on", then all those phases are required, and not "at least one".
@som-snytt in the interest of moving 2.13.15 ahead I'd like to focus on what we need for that, so I submitted a minimal diff (#10858). Can we go ahead with this for now? The remaining changes from my PR to this one: https://github.com/lrytz/scala/compare/pr10856light...lrytz:scala:pr10856?expand=1 What we can address after 2.13.15
Can you summarize what else is in the remaining diff? Performance improvements, debug logging, code cleanups. |
On duplicate names, I mention somewhere that Scala 3 uses a fixed "spine" of phases which supports name duplication. One could explore how options should work that rely on names. Scala 3 options don't use phase id. Also phase replacement was potentially a feature. |
14c42e4
to
84d4940
Compare
val help = if (knownNames.contains(name)) "" else | ||
knownNames.filter(util.EditDistance.levenshtein(name, _) < 3).toList match { | ||
case Nil => "" | ||
case close => s" - did you mean ${util.StringUtil.oxford(close, "or")}?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mayte this doesn't carry its weight? can we do without?
addConstraint(p.phaseName, end.phaseName, Follows) | ||
} | ||
if (warnAll) | ||
dropped.foreach(p => warnings.addOne(s"Component ${p} dropped due to bad constraint")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this warning seems redundant, at least in the check files
val purgedConstraints = constraints.filterInPlace { | ||
case (from, to, w) => !dropped.contains(from) && !dropped.contains(to) | ||
}.toList | ||
new DependencyGraph(start.phaseName, phases.iterator.map(p => p.phaseName -> p).toMap).tap { graph => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the advantage of the new approach of collecting constraints before creating the DependencyGraph
?
84d4940
to
a36cd77
Compare
-Werror
on bad phase config. Include core phase names when checking for typos in constraints.Previous description that pertains to commits merged previously:
Don't issue "phase" warnings under Scaladoc, to minimize build noise. There is little peril in not warning, since errors in plugin configuration are likely to be seen already when compiling.
The motivating use case is that a typo in a "runsBefore pickler" constraint for Scala-js was corrected but warned anyway in Scaladoc, which has no pickler phase.
Previously to this follow-up PR, "better monadic for" would warn for "runsBefore patmat". This PR reverts the fix of adding mock components to Scaladoc just for these constraints. Instead, Scaladoc does not warn by default if a constraint does not name a component. (It will warn under
-Vdebug
.)This is deemed useful and benign for the use cases described: a plugin "runsBefore" a compiler phase that does not exist in Scaladoc. The compiler warns and offers spelling advice.
Both tools warn if a plugin component is not installed because it is not "reachable" in the graph of phase constraints.
Note that is feasible for a component to have no "runsAfter" constraint, if another component "runsBefore" it.
The net difference with 2.13.14 is that the compiler will never silently omit a plugin phase. This PR follows 2.13.14 in being more circumspect about bad "runsBefore" constraints, but also warns about typos.
Follows up commits merged for scala/bug#13028