Skip to content

Better error messages in function calls.#242

Merged
ahejlsberg merged 4 commits into
masterfrom
argumentTypeErrors
Jul 25, 2014
Merged

Better error messages in function calls.#242
ahejlsberg merged 4 commits into
masterfrom
argumentTypeErrors

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

Fixes #93.
This is an evolution of #220.

Fixes #93.
This is an evolution of #220.
@ahejlsberg

Copy link
Copy Markdown
Member Author

@DanielRosenwasser @JsonFreeman This is an evolution of Daniel's branch. I have introduced a new error message of the form:

Argument type '{0}' is not assignable to parameter type '{1}'.

This error is used as the top-level error in an elaborated error message when none of the candidate signatures are applicable. The error reporting is based on the last candidate signature and uses the offending argument expression as the error span as Jason suggested. Overall this leads to a much better error reporting experience.

An alternative for the error message might be

Argument type '{0}' is not compatible with parameter type '{1}'.

It reads a little better even if "compatible with" isn't exactly the correct technical term.

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.

Should we mask 'unknown' type in message?

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.

Definitely

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Easily done, we can just associate the name "any" with the unknownType instance. But I kind of like "unknown" as it indicates that the type came about because of an error.

@mhegazy

mhegazy commented Jul 25, 2014

Copy link
Copy Markdown
Contributor

👍

Comment thread src/compiler/diagnosticMessages.json Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you make this

"Argument of type '{0}' is not assignable to parameter of type '{1}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I like that.

@ahejlsberg

Copy link
Copy Markdown
Member Author

Changed error message to

Argument of type '{0}' is not compatible with parameter of type '{1}'.

@DanielRosenwasser

Copy link
Copy Markdown
Member

@ahejlsberg, the Travis build failed, but I ran into this situation earlier, all you have to do is merge from master and it should be good.

Also 👍

@CyrusNajmabadi

Copy link
Copy Markdown
Contributor

The error baselines look great!

Accepting new baselines (not sure why this wasn't already done).
ahejlsberg added a commit that referenced this pull request Jul 25, 2014
Better error messages in function calls.
@ahejlsberg ahejlsberg merged commit e0b3312 into master Jul 25, 2014
@ahejlsberg ahejlsberg deleted the argumentTypeErrors branch July 25, 2014 13:54
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Errors] Message quality degradation for overload resolution errors

5 participants