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

Allow ParsedHashDirectives to take non string arguments #17206

Merged
merged 21 commits into from
Jun 17, 2024

Conversation

KevinRansom
Copy link
Member

@KevinRansom KevinRansom commented May 21, 2024

Requires fslang approval : fsharp/fslang-suggestions#1368

Fixes: #17209 , #17240

  • Allow ParsedHashDirectives to take non string arguments
  • Support LangVersion flag
  • Add integer arguments for nowarn
  • Allow nowarn to be prefixed with FS
  • #nowarn tests
  • Allow time to take non string argument (on/off)
  • #time tests
  • #r tests

@KevinRansom KevinRansom requested a review from a team as a code owner May 21, 2024 19:46
@KevinRansom KevinRansom marked this pull request as draft May 21, 2024 19:46
Copy link
Contributor

github-actions bot commented May 21, 2024

❗ Release notes required


✅ Found changes and release notes in following paths:

Warning

No PR link found in some release notes, please consider adding it.

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/8.0.400.md No current pull request URL (#17206) found, please consider adding it
LanguageFeatures.fsi docs/release-notes/.Language/preview.md No current pull request URL (#17206) found, please consider adding it

@KevinRansom KevinRansom force-pushed the directives branch 5 times, most recently from fde5c2d to e32f4a9 Compare May 24, 2024 02:12
@KevinRansom KevinRansom changed the title Tweak Directives Allow ParsedHashDirectives to take non string arguments May 25, 2024
@KevinRansom KevinRansom marked this pull request as ready for review May 25, 2024 07:03
@abelbraaksma
Copy link
Contributor

abelbraaksma commented May 25, 2024

Fixes: #17209

did you (also) mean #17240? It is mentioned in the preview.md release notes. And this closed suggestion: fsharp/fslang-suggestions#1364.

Considering this is a language change now (if I understand it correctly #nowarn "12" and #nowarn 12 are now both allowed, same for #time "on" and #time on), I propose we (I mean: I don't mind doing it) write an RFC for this. I don't mean to slow-down progress, but otherwise we won't catch this in the F# spec effort.

Copy link
Contributor

@abelbraaksma abelbraaksma left a comment

Choose a reason for hiding this comment

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

I really like this change, just a few questions:

Comment on lines 51 to 52
(Warning 203, Line 3, Col 1, Line 3, Col 11, "Invalid warning number 'FS'")
(Warning 203, Line 6, Col 1, Line 6, Col 13, "Invalid warning number 'FS'")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are FSBLAH and "FSBLAH", and ACME and "ACME" not an error? Conversely, if these aren't errors, why is FS and "FS" an error?

Just tested it with latest RTM, has this always been an error?

image

and even this:
image

this is so odd...

Copy link
Member Author

@KevinRansom KevinRansom May 25, 2024

Choose a reason for hiding this comment

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

Deleted the original because I was spouting garbage.

replaced with:
Okay, I looked a bit harder, it is as you would suspect "by design"; back in the olden days, I.e pre-dotnet SDK "ACME" would have originally failed, however, because in the dotnet SDK different build targets use
<NoWarn></NoWarn> for disabling warnings

For example:

  • C# uses CS, F# uses FS, Nuget uses NU.

Probably it would have been smarter to filter that out in the build target, but we missed that opportunity, so now a valid nowarn value is:
FSn or n - where n is any valid 32bit decimal integer or XXXX
And any other value is ignored, because it could be targeted at a different build target.

@abelbraaksma
Copy link
Contributor

abelbraaksma commented May 25, 2024

Considering the long ident change, does this mean #r "System.Core" and #r System.Core are now both allowed?

EDIT: checking your referenced issues, the answer is: yes 👍. I've tried to capture all these changes here: fsharp/fslang-suggestions#1368.

@KevinRansom
Copy link
Member Author

Considering the long ident change, does this mean #r "System.Core" and #r System.Core are now both allowed?

Sigh!!!!, I didn't intend for that to work.
#I and #r and #r nuget
require :, \ and / which means we would have to teach the parser paths and URIs.

@KevinRansom
Copy link
Member Author

@abelbraaksma huge thanks for taking care of the fslang suggestion, I miss having an active PM to keep me on the true path of righteousness.

@abelbraaksma
Copy link
Contributor

abelbraaksma commented May 26, 2024

I miss having an active PM to keep me on the true path of righteousness.

You're too kind!!! Are you offering me job? 😆jk. But seriously, no worries, I'm happy to help :).

require :, \ and / which means we would have to teach the parser paths and URIs.

Not entirely. It could just be that simple paths that are in scope are allowed without quotes, anything else needs quotes. Just like you don't need quotes on the commandline, unless you have spaces in the file names.

But we can decide that in the lang suggestion, of course.

Another way for this change is that you keep the information after you parse it. That way, it is not that all hash directives can now understand all kinds of arguments. That way, you can pick and choose per directive.

Copy link
Contributor

@abelbraaksma abelbraaksma left a comment

Choose a reason for hiding this comment

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

Some suggestions, nits below:

Copy link
Member

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

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

Marking this as waiting for RFC then. Otherwise LGTM :)

@edgarfgp
Copy link
Contributor

Now with #17140 merged. Looking forward to have this in 👍🏻

@psfinaki
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@abonie abonie dismissed psfinaki’s stale review June 17, 2024 17:27

Petr said it's fine

@KevinRansom KevinRansom merged commit 836d4e0 into dotnet:main Jun 17, 2024
30 checks passed
@nojaf
Copy link
Contributor

nojaf commented Jun 18, 2024

@Martin521
Copy link
Contributor

@KevinRansom
I have a question regarding this PR, specifically about this function, which I will need to touch for my current work on "scoped #nowarn".

  1. Do we really need the feature flag here? The only incompatibility scenario that I see here without that flag is the following:

    • Somebody has "illegally" used the new feature already, say #nowarn FS0025.
    • The directive was silently swallowed by earlier compilers, with no effect.
    • The file contains a match expression that creates a warning FS0025.
    • They somehow rely on that warning being emitted.
    • They now switch to the F# 9.0 compiler, with language version, say, 6.0.
    • The warning is suppressed.

    This scenario (specifically the point about relying on a warning in legacy code) seems to be so unlikely that I wonder if we can remove the flag in this function.

  2. Should we still want to safeguard against such a scenario, then we should, for the String case, pass the flag as last argument to the GetWarningNumber function.

I am not sure if I am overlooking something, I am therefore reaching out for advice. When I touch the function anyway, should I consider 1 or 2 above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Allow #nowarn to support the FS prefix on error codes to disable warnings
7 participants