Skip to content
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

Improve error reporting: provide better literal suffix description #1129

Closed
Tracked by #1103
smoothdeveloper opened this issue Apr 28, 2016 · 10 comments
Closed
Tracked by #1103

Comments

@smoothdeveloper
Copy link
Contributor

smoothdeveloper commented Apr 28, 2016

What

let foo = 1up

This is not a valid numeric literal. Sample formats include 4, 0x4, 0b0100, 4L, 4UL, 4u, 4s, 4us, 4y, 4uy, 4.0, 4.0f, 4I

Why

It is difficult to remember:

  • the valid suffixes
  • what exact type they correspond to (despite they are kind of logical, if I made a mistake, better remind me the type as well)
  • I was looking for decimal but it isn't there

How

Bonus point if we instead of 4 we show 42 or the actual value.

This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0b0001 (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1ui (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)
#1103

@smoothdeveloper
Copy link
Contributor Author

note also that let a = 0m works but let a = 0f doesn't which I think is inconsistent.

@smoothdeveloper
Copy link
Contributor Author

Question: why do UL and L need to be uppercased while others are all lowercase only?

@vasily-kirichenko
Copy link
Contributor

Question: why do UL and L need to be uppercased while others are all lowercase only?

About l vs L, my guess is that's something like 21l is very hard to read. I'm not sure about u vs U though.

@smoothdeveloper
Copy link
Contributor Author

@vasily-kirichenko I see, what about the one for BigInteger? 21i vs 21I I guess Big Integer = Big I :)

@forki
Copy link
Contributor

forki commented Apr 28, 2016

We should not question the syntax here. That is pretty much fixed. This
should only be about the error messages
On Apr 28, 2016 12:24 PM, "Gauthier Segay" notifications@github.com wrote:

@vasily-kirichenko https://github.com/vasily-kirichenko I see, what
about the one for BigInteger? 21i vs 21I I guess Big Integer = Big I :)


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#1129 (comment)

@smoothdeveloper
Copy link
Contributor Author

@forki: do you think the proposed error message (check on github itself due to edits) is an enhancement?

@dsyme
Copy link
Contributor

dsyme commented Apr 28, 2016

Adding the samples is ok, but as a matter of principle please use sentences, rather than phrases:

This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0b0001 (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1ui (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)

It's important to say "include" because the numeric literals are extensible through the QZRING feature.

@smoothdeveloper
Copy link
Contributor Author

@dsyme updated, thanks for feedback, maybe you should consider putting some guidelines on #1103 regarding how to word those messages.

I still think the final messages should be created/edited by MS with concern at consistency, comprehensibility and conciseness.

forki added a commit to forki/visualfsharp that referenced this issue May 3, 2016
@forki
Copy link
Contributor

forki commented May 3, 2016

PR at #1148
Regarding "bonus points": we failed to parse the numeral so we can't say what the "actual value" is here.

forki added a commit to forki/visualfsharp that referenced this issue May 3, 2016
KevinRansom added a commit that referenced this issue May 3, 2016
Improve numeric literal error - fixes #1129
@toburger
Copy link

toburger commented Jun 25, 2016

In the error message the byte literal is wrong: should be 1uy, not 1ui: https://github.com/Microsoft/visualfsharp/blob/44b29e4838d675350da9beccd962a7f952a0f1b8/src/fsharp/FSComp.txt#L980

toburger pushed a commit to toburger/visualfsharp that referenced this issue Jul 1, 2016
dsyme added a commit that referenced this issue Jul 1, 2016
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

No branches or pull requests

5 participants