Summary
src/generics.jl locates the function signature with:
fn_pattern = Regex("fn\\s+$(func_name)\\s*(?:<[^{]*?>)?\\s*\\(")
This rejects valid generic parameter lists that contain {...} blocks, such as const-generic defaults or trait bounds with const expressions. In those cases _parse_fn_arg_types returns no argument types even though the signature is otherwise parseable.
Reproducer
using RustCall
RustCall._parse_fn_arg_types(
"fn foo<const N: usize = { 1 + 2 }, T>(x: T) -> T { x }",
"foo",
)
# => String[]
RustCall._parse_fn_arg_types(
"fn foo<T: Trait<{ 1 + 2 }>>(x: T) -> T { x }",
"foo",
)
# => String[]
Expected
Both calls should return:
Actual
The regex fails to match the fn ... <...>( prefix as soon as { appears inside the generic parameter list, so the function returns an empty vector.
Affected Code
Notes
Nested generics like Vec<Option<T>> appear to work here because the regex can still backtrack to the final > before (. The failure mode is specifically braces inside the generic parameter list.
Summary
src/generics.jllocates the function signature with:This rejects valid generic parameter lists that contain
{...}blocks, such as const-generic defaults or trait bounds with const expressions. In those cases_parse_fn_arg_typesreturns no argument types even though the signature is otherwise parseable.Reproducer
Expected
Both calls should return:
["T"]Actual
The regex fails to match the
fn ... <...>(prefix as soon as{appears inside the generic parameter list, so the function returns an empty vector.Affected Code
src/generics.jl:750-758Notes
Nested generics like
Vec<Option<T>>appear to work here because the regex can still backtrack to the final>before(. The failure mode is specifically braces inside the generic parameter list.