fparser icon indicating copy to clipboard operation
fparser copied to clipboard

namelist false match error

Open rupertford opened this issue 6 years ago • 1 comments

The f2003 namelist match rule r552 produces an assertion error when a variable starting with the name `namelist' is initialised ...

program test
  NamelistFile = "dummy file"
end program

rupertford avatar Jan 16 '19 14:01 rupertford

Just tried to make a PR to fix this, based on the issue 4 fix and the above snippet, but the error does not occur. (What I think is) the bug is still there, if string[:8].upper() != 'NAMELIST':, but it seems it's no longer being triggered, perhaps because things are being called in a different order now.

bblay avatar Feb 11 '22 15:02 bblay

There still seems to be a problem around this issue. Here is my test case:

program test

  type(foo_type), pointer :: namelist_ptr

  namelist_ptr => null()

end program test

Parsing this using fparser2 <filename> gives

  File "/net/home/h06/mhambley/Woomera/PointerAssignment/venv/lib/python3.7/site-packages/fparser/two/Fortran2003.py", line 4677, in match
    assert not fst, repr((fst, parts))
AssertionError: ('_ptr => null()', [])

It looks like the "namelist" at the start of the variable name is being interpreted as a "namelist" keyword.

MatthewHambley avatar May 11 '23 14:05 MatthewHambley

I still get an error for both examples on master. I'll take it on as I have a fix, but it will take a little while to tidy up the class and add the required tests.

rupertford avatar May 11 '23 22:05 rupertford

Created branch 165_namelist_error

rupertford avatar May 11 '23 22:05 rupertford