-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Preprocessor defines overrides fortran keyword resulting in scope errors #72
Comments
Hi @gbogopolsky good catch. This is indeed a bug. As you can tell I don't tend to work with I will fix it ASAP (hopefully it's trivial to fix) |
So I had a look, the error you are getting from pytest is because of the unittest breaks if you remove lines 23-26 if you have a look at the file_path = test_dir / "subdir" / "test_select.f90"
string += comp_request(file_path, 21, 7)
string += comp_request(file_path, 23, 7) # <- line 24 in the file and column 8
string += comp_request(file_path, 25, 7) # <- line 26 in the file and column 8
string += comp_request(file_path, 30, 7) If you remove lines 23-26 the unittest will break because the completion request will return |
Okay I had a look and it seems okay to me. You can see that the single If you try and run a completion request from fortls.py --debug_filepath subdir/test_select.f90 --debug_rootpath . --debug_completion --debug_line 22 --debug_char 8 you should get an output similar to this (I have more Source directories due to unreleased features I am testing).
Can you post the code that generate this?
|
So I do think that the error is from The diagnostic error at To get to the bottom of this can you answer the following please. Firstly post the output of this command fortls --debug_filepath test_selected.f90 --debug_rootpath . --debug_diagnostics then
|
Alright, so in order:
{
"pp_suffixes": [".f90"],
"include_dirs": [],
"pp_defs": {
"PetscInt": "integer",
"PetscScalar": "real(pr)",
"PetscBool": "logical(kind=4)",
"Mat": "type(tMat)",
"Vec": "type(tVec)",
"KSP": "type(tKSP)",
"PC": "type(tPC)",
"VecScatter": "type(tVecScatter)",
"IS": "type(tIS)",
"PetscLogStage": "integer",
"PetscErrorCode": "integer"
}
}
{
"fortran-ls.hoverSignature": true,
"fortran-ls.autocompletePrefix": true,
"fortran-ls.variableHover": true,
"fortran-ls.lowercaseIntrinsics": true,
"fortran-ls.executablePath": "[correctPathToFortls]",
"fortran.linter.includePaths": [
"/usr/local/opt/petsc/include"
],
"fortran.linter.compiler": "Disabled"
} I hope this helps you. |
|
And just to check, you are using fortls v 2.2.5? |
Still, it's strange that you do not have this problem... I will check on my Windows machine, if it changes something, I'll get back to you. |
Same behavior is observed on Windows with |
To be honest, I wouldn't expect conda-forge to be any different.
I figured it out. You define a preprocessor variable |
Damn, that's so evident now that you say it... For now, I will remove the Anyway, thank you very much for your help and your availability. I think I would be interested to help you with the code on this project, but I do not have the time currently thanks to my PhD. But I'll keep it in mind :) |
Yeah preprocessor definitions are a bit flimsy because they are implemented as string substitutions. That means that every instance of the word All of this would be so much simpler if Fortran disallowed the use of reserved keywords as variables... I think the correct way to handle this would be instead of using string substitutions to register preprocessor statements as Fortran variables/functions/subroutines. However, before I do that I want to increase the code coverage of the preprocessor since the original implementation is the definition of spaghetti code. I would leave this issue open since it is technically a bug |
Good luck for the preprocessor and thanks for the title update, it was indeed out of date. |
Hi,
First thank you for taking up this project and your numerous fixes!
I recently noticed a bug when a single
TYPE IS
is called in aSELECT TYPE
block when an identifier is associated to the selector. The following error is raised in vscode:Invalid parent for "TYPE" declaration
.I am able to reproduce this behavior by removing lines 23 to 26 included in
test/test_source/subdir/test_select.f90
, yielding:This causes the
test/test_server.py::test_comp
to fail withTypeError: object of type 'NoneType' has no len()
.To my knowledge, such a structure is valid (at least it compiles and works as expected on the Intel classic compiler).
The text was updated successfully, but these errors were encountered: