Skip to content

Conversation

@isaacabraham
Copy link
Contributor

@isaacabraham isaacabraham commented Jan 4, 2020

Fixes #8091. This provides custom error messages for four cases of mismatched anonymous records:

  1. Source is a subset of destination.
  2. Source is a superset of destination.
  3. Source and destination overlap but both have differences.
  4. Source and destination are completely different.

Wording might need to be changed!

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

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

Thanks! This is a great change to the error messages. Just some style nits.

Requesting changes since there are some small test updates that need to be made in the baseline files. You can see which ones here: https://dev.azure.com/dnceng/public/_build/results?buildId=472147&view=ms.vss-test-web.build-test-results-tab&runId=15028460&resultId=100248&paneView=debug

Since this is an error message update there's nothing special here, just copy/pasting the new expected error message into the baseline. It's kind of annoying.

@smoothdeveloper
Copy link
Contributor

just copy/pasting the new expected error message into the baseline. It's kind of annoying.

This can be made less annoying, following the instructions there:

https://github.com/dotnet/fsharp/tree/master/tests/fsharp#workflow-when-adding-or-fixing-tests

@isaacabraham isaacabraham changed the title Initial attempt at better anonymous record reporting. WIP: Better anonymous record reporting Jan 5, 2020
@isaacabraham
Copy link
Contributor Author

@smoothdeveloper I couldn't actually figure out what to do with that script or how to run those BSL tests locally (they weren't even in the solution). How do I do it?

@smoothdeveloper
Copy link
Contributor

smoothdeveloper commented Jan 5, 2020

@isaacabraham, have you been able to run tests under: https://github.com/dotnet/fsharp/blob/master/tests/fsharp/tests.fs ?

after those ran, the .err files will contain the actual output, you can then adjust the script (it handles the folders explicitly, you need to put the folder names that you are interested in) and run it to copy the .err into .bsl files, review and commit/push.

edit:
me changing a .bsl to make a test fail
image

running the script (with folder of the test added)

C:\dev\src\github.com\Microsoft\masterfsharp\tests\fsharp\core\byrefs\test.bsl not matching, replacing with C:\dev\src\github.com\Microsoft\masterfsharp\tests\fsharp\core\byrefs\test.err

running the test again:

image

@isaacabraham isaacabraham changed the title WIP: Better anonymous record reporting Better anonymous record reporting Jan 6, 2020
Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

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

Awesome work, thanks!

@abelbraaksma
Copy link
Contributor

abelbraaksma commented Jan 8, 2020

Wording might need to be changed!

In the original issue I proposed an alternative text, but it looks like you already made it far better than the original idea. I do have a few suggestions, though, feel free to use them, or not ;)

tcAnonRecdFieldNameMismatch,"This anonymous record has the following missing fields '%s' and the following unexpected extra fields '%s'."

Error messages in F# typically don't use determiners, for consistency, I suggest to simplify it like this (which also removes a redundancy): "Anonymous record misses fields '%s' and has unexpected fields '%s'."

tcAnonRecdFieldNameSubset,"This anonymous record is missing the following fields: '%s'. Please add them."

Same here, I'd suggest: "Anonymous record misses fields '%s'."

tcAnonRecdFieldNameSuperset,"This anonymous record has the following unexpected extra fields '%s'. Please remove them."

And here it would become: "Anonymous record has unexpected fields '%s'."

tcAnonRecdFieldNameDifferent,"This is the wrong anonymous record. The expected record has the following fields: '%s'."

Perhaps something like: "Unexpected anonymous record. The expected anonymous record has fields: '%s'."

@isaacabraham
Copy link
Contributor Author

@abelbraaksma I'll give it a bash and see how it "looks" locally. A few ideas I had in the past days looked good on paper or in my mind but when I tried them, they didn't print out as well.

We can always iterate on this in the future - I don't believe there's a "no breaking changes" on error messages.

@abelbraaksma
Copy link
Contributor

We can always iterate on this in the future

I agree, even more so for compiler errors.

@abelbraaksma
Copy link
Contributor

Error messages in F# typically don't use determiners, for consistency

While I said that myself, this turns out to be untrue, we do have errors that start with "this expression .... " etc. Right now I'm not so sure if there's any rule-of-thumb w.r.t. grammar/style/wording of errors.

@cartermp
Copy link
Contributor

cartermp commented Jan 8, 2020

@isaacabraham is the error message itself how you'd like it?

@isaacabraham
Copy link
Contributor Author

I'm personally satisfied with it, at least as a means to get feedback from others. It should be consistent enough that tooling could generate fixes on top of it as well.

@cartermp
Copy link
Contributor

cartermp commented Jan 8, 2020

I'll merge this. The message is easy to adjust after the fact, so let's get it in!

@cartermp cartermp merged commit 0a0889e into dotnet:master Jan 8, 2020
@isaacabraham isaacabraham deleted the fix-8091 branch January 9, 2020 14:33
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
* Initial attempt at better anonymous record reporting.

* Update error texts and fix tests.

* Fix test, but for real this time.

* Fix another random BSL file.

* Next random file fix!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Error Reporting: Better description for mismatched anonymous records.

4 participants