Skip to content

Issue 9631 - Error message not using fully qualified name (part 2)#7441

Merged
dlang-bot merged 3 commits intodlang:masterfrom
ntrel:qual-incompatible
Dec 16, 2017
Merged

Issue 9631 - Error message not using fully qualified name (part 2)#7441
dlang-bot merged 3 commits intodlang:masterfrom
ntrel:qual-incompatible

Conversation

@ntrel
Copy link
Copy Markdown
Contributor

@ntrel ntrel commented Dec 15, 2017

@JinShil Following on from #7405.

  • Disambiguate incompatible type errors.
  • Add "both operands are of type '%s'" error message case.

The latter saves the programmer time reading the error when there are two types with long qualification.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request, @ntrel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Auto-close Bugzilla Description
9631 Error message not using fully qualified name when appropriate.

}
else if (e1.type.equals(e2.type))
{
error("incompatible types for ((%s) %s (%s)): both operands are of type '%s'",
Copy link
Copy Markdown

@ghost ghost Dec 15, 2017

Choose a reason for hiding this comment

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

I think it would be better to denote that the operator %s cannot be used for two variables of type %s.
But maybe in another PR ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reworded in f73a72b.

@ntrel ntrel force-pushed the qual-incompatible branch from 41078c6 to e233e2e Compare December 15, 2017 13:15
Disambiguate incompatible type errors.
Add "both operands are of type '%s'" error message.
@ntrel ntrel force-pushed the qual-incompatible branch from e233e2e to cf01f68 Compare December 15, 2017 14:19
if (e1.op == TOKtype || e2.op == TOKtype)
{
error("incompatible types for ((%s) %s (%s)): cannot use '%s' with types", e1.toChars(), Token.toChars(thisOp), e2.toChars(), Token.toChars(op));
error("incompatible types for ((%s) %s (%s)): cannot use '%s' with types",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can change ((%s) %s (%s)) to `(%s) %s (%s)`. That is, lose the outer parentheses and surround the expression in back ticks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, those single quotes should be backticks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, but I was just following the existing format for these errors. I'll do as you suggest for the new error added in this PR, but the other ones can be fixed in a separate PR.

a.x = x;
a.y = y;
return a;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why was this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It doesn't seem relevant to the test - should I restore it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, it does seem unnecessary, but I don't think it belongs in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, restored.

F x = tem!().F();
}

void main()
Copy link
Copy Markdown
Contributor

@JinShil JinShil Dec 15, 2017

Choose a reason for hiding this comment

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

Why the refactoring of this test case? There should only be changes to the error messages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought it was a bit simpler whilst still essentially testing the same thing. But I suppose it may be worth having both the two template version and the new changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Restored the two template version.

}
else if (e1.type.equals(e2.type))
{
error("invalid operation for `(%s) %s (%s)` with both operands of type `%s`",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the error message is still bad. My first review comment was more accurate. Maybe:

"the %s operator is not supported for two operands of type %s ((%s) %s (%s))".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure there's much difference, but if necessary I'll update it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

necessary

@ntrel ntrel force-pushed the qual-incompatible branch from f73a72b to 51b0dce Compare December 16, 2017 12:38
@ntrel
Copy link
Copy Markdown
Contributor Author

ntrel commented Dec 16, 2017

I've reverted the rewording of the new error message, so it now just follows the existing format, and does not use backticks. The backtick change should be done in a separate PR as it affects about 8 error messages in dmd, I could do it if this gets merged soon.

if (e1.op == TOKtype || e2.op == TOKtype)
{
error("incompatible types for ((%s) %s (%s)): cannot use '%s' with types", e1.toChars(), Token.toChars(thisOp), e2.toChars(), Token.toChars(op));
error("incompatible types for ((%s) %s (%s)): cannot use '%s' with types",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This error message doesn't seem to have a test case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@JinShil What about fail_compilation/fail54.d and fail_compilation/ice8511.d?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I realize that error message didn't actually change.

@JinShil JinShil dismissed their stale review December 16, 2017 14:16

My mistake

@dlang-bot dlang-bot merged commit 6504493 into dlang:master Dec 16, 2017
@ntrel ntrel deleted the qual-incompatible branch December 18, 2017 14:51
@ntrel
Copy link
Copy Markdown
Contributor Author

ntrel commented Dec 18, 2017

Thanks for reviewing.

The backtick change should be done in a separate PR

See #7464.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants