-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ref #1589: Add error message for bad symbolic reference. #3605
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
Ref #1589: Add error message for bad symbolic reference. #3605
Conversation
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Commit Messages
We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).
Please stick to these guidelines for commit messages:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Added" instead of "Add")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
|the classpath might be incompatible with the version used when compiling $src.""" | ||
ctx.error(errMsg) | ||
if (ctx.debug) throw new Error() | ||
val errMsg = BadSymbolicReference(location, name, denot.owner, src) |
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.
Should be a def
name: String, | ||
denotationOwner: Symbol, | ||
src: String | ||
)(implicit ctx: Context) extends Message(BadSymbolicReferenceID) { |
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 would change BadSymbolicReference
so that it only has denot: SymDenotation
. You can derive location
, name
, owner
and src
from denot
.
@@ -18,6 +18,8 @@ import util.Stats | |||
import java.util.WeakHashMap | |||
import config.Config | |||
import config.Printers.{incremental, noPrinter} | |||
import reporting.diagnostic.Message | |||
import reporting.diagnostic.messages._ |
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.
Only import what you need
private val (location, src) = | ||
if (file != null) (s" in $file", file.toString) | ||
else ("", "the signature") | ||
private val name = ctx.fresh.setSetting(ctx.settings.YdebugNames, true).nameString(denot.name) |
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.
We usually don't create fields to only store temporary values. If you need to precompute something for msg
, you can use a block:
val msg = {
val tmp1 = ...
val tmp2 = ...
doSomethingWith(tmp1, tmp2)
}
If a temporary computation is shared like name
, we usually make it a def
. We might want to create a field if we don't want to perform a computation multiple times. In this case I guess it make sense to keep name
a field since ctx.fresh...
may be expensive.
val msg = | ||
hl"""Bad symbolic reference. A signature$location | ||
|refers to $name in ${denotationOwner.showKind} ${denotationOwner.showFullName} which is not available. | ||
|refers to $name in ${denot.owner.showKind} ${denot.owner.showFullName} which is not available. |
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.
Here you can also store the result of owner
in a temporary val
within the block
Regarding #1589, this PR addresses the following error: