Skip to content

Commit

Permalink
Fix crash when function contains fused extension type (#6204)
Browse files Browse the repository at this point in the history
  • Loading branch information
matusvalo committed May 21, 2024
1 parent cd5a967 commit 9e81f99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cython/Compiler/PyrexTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5042,7 +5042,7 @@ def best_match(arg_types, functions, pos=None, env=None, args=None):
if len(candidates) == 1:
return candidates[0][0]
elif len(candidates) == 0:
if pos is not None:
if pos is not None and errors:
func, errmsg = errors[0]
if len(errors) == 1 or [1 for func, e in errors if e == errmsg]:
error(pos, errmsg)
Expand Down
10 changes: 10 additions & 0 deletions tests/errors/fused_types.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ cdef void contents_unfindable1(cython.integral x):
z: floating = 1 # note: cdef variables also fail with an error but not by the time this test aborts
sz = sizeof(floating)

cdef fused fused3:
Foo
cython.int

cdef cython.integral func_with_fused_extension(fused3 foo):
return x

func_with_fused_extension(5)

_ERRORS = u"""
11:15: fused_type does not take keyword arguments
Expand All @@ -112,4 +120,6 @@ _ERRORS = u"""
87:16: Type cannot be specialized since it is not a fused argument to this function
87:16: Type cannot be specialized since it is not a fused argument to this function
87:16: Type cannot be specialized since it is not a fused argument to this function
93:5: Return type is a fused type that cannot be determined from the function arguments
96:0: Invalid use of fused types, type cannot be specialized
"""

0 comments on commit 9e81f99

Please sign in to comment.