[RFC FS-1146 Discussion] Scoped Nowarn #786
Replies: 7 comments 4 replies
-
The RFC contains quite a few details that may be contentious. Early agreement on a final version is much appreciated because of the ongoing implementation work. |
Beta Was this translation helpful? Give feedback.
-
The nature of scoping (basically begin-end for directives) requires linear ordering of lines in a file. Since For files that have 1 or more This is how the documentation currently describes nowarn for all files anyway (which is wrong and this RFC will change it anyway). So in that case, it is not causing a regressed mismatch against the documented state. https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/compiler-directives#preprocessor-directives. |
Beta Was this translation helpful? Give feedback.
-
I like the simplicity of this rule and support this change. |
Beta Was this translation helpful? Give feedback.
-
Tomas and I had a chat about this, and I think we have level-set in our minds how we should think about this feature. Whilst I have thoughts about the syntax of #nowarn and #warnon they are of a secondary nature, although I believe the C# syntax offers a very good guide and decent alignment with the .NET ecosystem. The interaction with #line is the more interesting in my mind, because it offers the opportunity for deviations and strange behaviour. #nowarn and the obverse should work only against the actual source file being compiled, the #line directive should only impact the file and line number of error messages. For nowarn they are irrelevant, Here is a C# example that I think demonstrates what I mean. As you can see from the compiler output, the #line had no impact on the behavior of the nowarn. I understand that the current implementation of the compiler makes it harder to figure out how to achieve this behaviour. Since the parser tells the type checker the filename and line number (modified by the #line). I believe we can relatively easily figure out how to improve the nowarn behaviour so that it matches the C# behaviour, and probably simplify that wierd code too. What we can do, when we are building and typechecking always use the filename and line numbers from the original source file, ignoring #line and # n. Store the #n and #line we encounter in a table while lexing. When we use nowarn, always use these values. When producing error messages map them back to the #line values we stored during lexing. We can build the table here:https://github.com/dotnet/fsharp/blob/52133d002b14cbf5d16dbd771a7dda23bb29a6d4/src/Compiler/lex.fsl#L818 Fixing it won't be easy, but certainly not impossible. And we can probably reproduce the current wierd behavior on F# 8.0 too, if we really wanted to. |
Beta Was this translation helpful? Give feedback.
-
I have updated the RFC PR.
Feedback is appreciated. |
Beta Was this translation helpful? Give feedback.
-
How do you feel about the proposal to apply to scripts the same rules for #nowarn / #warnon as to |
Beta Was this translation helpful? Give feedback.
-
I need to come back to the discussion on line directives. While I do prefer the LAST proposal over the PREVIOUS one, I'd like to bring up some consequences of the LAST proposal that we should consider before finally deciding. Assume we parse a generated file When later checking a warning that carries the file index of There are, however, two issues. First, a section in Second, the file index is stored in a global table that - as far as I can see - is kept and grown through the lifetime of the compiler service process. Therefore, if Now, we know that in the typical fsyacc and fslex case, these issues don't come up. They might in other cases. So, I am not sure if we should continue on this track, or rather fall back on the PREVIOUS proposal. EDIT: |
Beta Was this translation helpful? Give feedback.
-
This is a discussion about RFC PR #782.
Any feedback about the PR is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions