diff options
Diffstat (limited to 'numpy')
-rwxr-xr-x | numpy/f2py/crackfortran.py | 10 | ||||
-rw-r--r-- | numpy/f2py/tests/test_callback.py | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 2aa8dc420..1149633c0 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -3232,11 +3232,11 @@ def vars2fortran(block, vars, args, tab='', as_interface=False): outmess('vars2fortran: No definition for argument "%s".\n' % a) continue if a == block['name']: - if block['block'] == 'function': - if block.get('result'): - # skip declaring function if its result is already declared - continue - else: + if block['block'] != 'function' or block.get('result'): + # 1) skip declaring a variable that name matches with + # subroutine name + # 2) skip declaring function when its type is + # declared via `result` construction continue if 'typespec' not in vars[a]: if 'attrspec' in vars[a] and 'external' in vars[a]['attrspec']: diff --git a/numpy/f2py/tests/test_callback.py b/numpy/f2py/tests/test_callback.py index acf8c2392..6a59b6398 100644 --- a/numpy/f2py/tests/test_callback.py +++ b/numpy/f2py/tests/test_callback.py @@ -218,13 +218,13 @@ class TestF90Callback(util.F2PyTest): suffix = '.f90' code = """ -function gh17797(f, y) result(r) - external f - integer(8) :: r, f - integer(8), dimension(:) :: y - r = f(0) - r = r + sum(y) -end function gh17797 + function gh17797(f, y) result(r) + external f + integer(8) :: r, f + integer(8), dimension(:) :: y + r = f(0) + r = r + sum(y) + end function gh17797 """ def test_gh17797(self): |