fix(golike): register generic functions with [...] type params#484
Open
StressTestor wants to merge 1 commit into
Open
fix(golike): register generic functions with [...] type params#484StressTestor wants to merge 1 commit into
StressTestor wants to merge 1 commit into
Conversation
Generic functions/methods with a square-bracket type-parameter list were
silently dropped. In golike.py, _expect_function_dec only handled '('
(value params) and '<' (the <> generics); a '[' (Scala def f[T](...), Go
1.18 func F[T any](...)) fell through to the else and bailed to
_state_global, so the function was never registered.
Adds a '[' branch + _generalize_type_params skipping the [...] list,
mirroring the existing <> _generalize, so the following '(' params
register the function. Affects all golike readers: go, scala, kotlin,
rust, swift, zig, solidity.
Covers the common def f[T](...) / func F[T any](...) shape; paren-less
generic defs remain dropped (same as the pre-existing paren-less-def
limitation).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what
generic functions/methods with a square-bracket type-param list were dropped or mis-parsed (no name, wrong param count). this registers them correctly.
why
in
golike.py, after a function name_expect_function_deconly handled((value params) and<(the<>generics). a[- Scaladef f[T](...)or Go 1.18func F[T any](...)- fell through to theelseand bailed back to_state_global, so the function was never registered. this affects every golike-based reader: go, scala, kotlin, rust, swift, zig, solidity.fix
one branch in
_expect_function_decthat skips the[...]list via_generalize_type_params, mirroring the existing<>_generalize. once the type params are skipped, the following(params register the function as normal.tests
testScala.py: generic method with one type param, with multiple type params, and a generic method inside a class body (the drop-in-context case)testGo.py:[T any]and multiple type params[T any, U any]known limitation
this covers the common
def f[T](...)/func F[T any](...)shape. paren-less generic defs like Scaladef empty[T]: List[T]are still dropped, same as the existing paren-less-def limitation - out of scope here, since closing it means changing how paren-less defs register in general.