-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
bug: Linter errors from include files reported in main file #931
Comments
Hey @albertziegenhagel thanks for the issue. Can you set the language type of the .inc file to I suspect that the file URI for the .inc file is not "registered" via our extension. Also, gfortran version are you using? |
The language type was already set to I am running gfortran
|
I would say the issue is that in compilers.ts#L144-L163 the |
Yes that is correct. The problem is that diagnostics should be created/destroyed when a file is opened/closed. We can't serve diagnostics to a file that has not been opened yet. In your case, you have opened the .inc file and consequently the error manifests as If the .inc file had not been opened, I think the expected behaviour would be to show no errors/warnings. |
Is there an existing issue for this?
Description
If a fortran file
A
includes another fileB
, and the file that is included (B
) has a syntax error in it, the linter errors (I am usinggfortran
) are incorrectly reported to be in the fileA
.As an example let file
A
beprog.f90
withand file
B
isinclude.inc
withintegers :: i
(note that there is a typo:
integers
instead ofinteger
).Here the linter error is reported in
prog.f90
line 2, column 9 but in fact, it is in include.inc.If I copy the
gfortran
command from theModern Fortran
output window to a terminal and invoke gfortran manually it reportsScreenshots
Expected Behaviour
That is actually not that easy to answer. One solution would be to report the errors in the
include.inc
file, but this could lead to problems when the file is included from multiple locations and each inclusion leads to different errors (as an example, one can fix the typo in theinclude.inc
file above, but add-Wunused-variable
to the linter arguments. In this case one will get a warning about an used variablei
in the example. But if we would include the same file from another subroutine wherei
is used, this will not trigger a warning).An alternative would be to show all warnings from the includes on the
include 'include.inc'
line inprog.f90
, but this way one might get a lot of warnings/errors in that single line and it will be hard to figure out where exactly they originate from.I am open for any other suggestions for solutions to that problem
Version of Modern Fortran
v3.4.2023062602
Version of Visual Studio Code
1.79.2
Platform and Architecture
Windows
Additional Information
No response
The text was updated successfully, but these errors were encountered: