Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@apiology
Copy link
Contributor

@apiology apiology commented Jul 1, 2025

This is the syntax used by Solargraph for generic type variables. e.g.:

# @generic T
# @param x [generic<T>]
# @return [generic<T>]
def identity(x)
  x
end

When experienced currently, sord emits generic[T], which isn't correct RBI/RBS, and also creates issues downstream in sorbet:

rbi/checkoff.rbi:6976: Malformed type declaration. Unknown type syntax. Expected a ClassName or T.<func> https://srb.help/5004
    6976 |  sig { params(o: generic[T], type: T.class_of(generic[T])).returns(generic[T]) }
                                                                              ^^^^^^^^^^

rbi/checkoff.rbi:6976: Malformed type declaration. Unknown type syntax. Expected a ClassName or T.<func> https://srb.help/5004
    6976 |  sig { params(o: generic[T], type: T.class_of(generic[T])).returns(generic[T]) }
                            ^^^^^^^^^^

rbi/checkoff.rbi:6976: Malformed type declaration. Unknown type syntax. Expected a ClassName or T.<func> https://srb.help/5004
    6976 |  sig { params(o: generic[T], type: T.class_of(generic[T])).returns(generic[T]) }
                                                         ^^^^^^^^^^

rbi/checkoff.rbi:6976: T.class_of needs a class or module as its argument https://srb.help/5004
    6976 |  sig { params(o: generic[T], type: T.class_of(generic[T])).returns(generic[T]) }
                                              ^^^^^^^^^^^^^^^^^^^^^^
  Note:
    You may wish to use T::Class, which doesn't have this restriction.
    For more information, see https://sorbet.org/docs/class-of#tclass-vs-tclass_of
  Autocorrect: Use -a to autocorrect
    rbi/checkoff.rbi:6976: Replace with T::Class[generic[T]]
    6976 |  sig { params(o: generic[T], type: T.class_of(generic[T])).returns(generic[T]) }
                                              ^^^^^^^^^^^^^^^^^^^^^^

apiology added 2 commits July 1, 2025 09:33
This is the syntax used by Solargraph for generic type variables.
@apiology
Copy link
Contributor Author

apiology commented Jul 1, 2025

I'll probably be back soon enough to implement the @generic tag, but I think this gets me past where I'm blocked by sord today in my workflow.

@apiology apiology marked this pull request as draft July 4, 2025 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant