nebius/SWE-bench-extra huggingface dataset:
Repository: stfc/fparser

Issue:
Module Procedures in a Fortran type
The following code is not parsed and then analyzed correctly with fparser 1:
```
module foo
    type, public :: grid_type
   contains
        procedure :: get_tmask
   end type grid_type
end module foo
```

Reason: The class Type does not contain an attribute "module_procedures".

Comments:

Patch:
diff --git a/src/fparser/one/block_statements.py b/src/fparser/one/block_statements.py
index a4f1cc6..af7d1c3 100644
--- a/src/fparser/one/block_statements.py
+++ b/src/fparser/one/block_statements.py
@@ -1239,7 +1239,8 @@ class EndType(EndStatement):
     blocktype = 'type'
 
 
-class Type(BeginStatement, HasVariables, HasAttributes, AccessSpecs):
+class Type(BeginStatement, HasVariables, HasAttributes, HasModuleProcedures,
+           AccessSpecs):
     """
     TYPE [[, <typ-attr-spec-list>] ::] <type-name> [( <type-param-name-list> )]
     <typ-attr-spec> = <access-spec> | EXTENDS ( <parent-type-name> )


Test patch:
diff --git a/src/fparser/one/tests/test_parsefortran.py b/src/fparser/one/tests/test_parsefortran.py
index 6481c61..62bf562 100644
--- a/src/fparser/one/tests/test_parsefortran.py
+++ b/src/fparser/one/tests/test_parsefortran.py
@@ -186,10 +186,10 @@ end module foo
     expected = ['  MODULE foo',
                 '    SUBROUTINE bar()',
                 '      REAL r',
-                '      IF (pc_get_lun() .ne. 6)'
-                + ' WRITE (pc_get_lun(), \'(  /, A, /, " P = ", i4,'
-                + ' " stopping c_flag=", a,  /, " print unit=", i8)\')'
-                + ' trim(title), pcpsx_i_pel(), trim(c_flag), pc_get_lun()',
+                '      IF (pc_get_lun() .ne. 6)' +
+                ' WRITE (pc_get_lun(), \'(  /, A, /, " P = ", i4,' +
+                ' " stopping c_flag=", a,  /, " print unit=", i8)\')' +
+                ' trim(title), pcpsx_i_pel(), trim(c_flag), pc_get_lun()',
                 '      IF (.true.) THEN',
                 '        CALL smth',
                 '      END IF ',
@@ -213,6 +213,30 @@ end module foo
     assert caught[1:] == expected
 
 
+def test_module_procedure():
+    '''
+    Tests a type that contains a procedure, and makes sure
+    it has a module_procedures attribute
+    '''
+    string = """
+module foo
+    type, public :: grid_type
+   contains
+        procedure :: get_tmask
+   end type grid_type
+end module foo
+"""
+
+    reader = fparser.common.readfortran.FortranStringReader(string)
+    mode = fparser.common.sourceinfo.FortranFormat.from_mode('free')
+    reader.set_format(mode)
+    parser = fparser.one.parsefortran.FortranParser(reader)
+    parser.parse()
+
+    # Fails if the class Type does not have a "module_procedures" attribute
+    parser.analyze()
+
+
 def test_f77():
     '''
     Tests inherited from implementation code.