-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
(This is not the 'correct' usage of the work namespace for Ruby, but hopefully you know what I mean)
If I have a namespaced class (by this I mean a class within a module) like:
class My::Class
attr_accessor :name: String
def initialize(name: String)
@name = name
end
end
class MyOtherClass
attr_accessor :data: My::Class
def initialize(data: My::Class)
@data = data
end
end
I get the following errors:
src/test.trb:12:1 - error TR1002: Unexpected token after parameter type for 'data' 'My::Class'
12 | def initialize(data: My::Class)
| ~
src/test.trb:12:25 - error TR1003: Expected ')'
12 | def initialize(data: My::Class)
| ~
[10:58:12 AM] Found 2 errors. Watching for file changes.
A handwritten version of this in plain ruby code is perfectly valid:
class My::Class
attr_accessor :name: String
def initialize(name: String)
@name = name
end
end
class MyOtherClass
attr_accessor :data
def initialize(data)
@data = data
end
endI tried to work around this by using Type Aliases:
class My::Class
attr_accessor :name: String
def initialize(name: String)
@name = name
end
end
type MyClass = My::Class
class MyOtherClass
attr_accessor :data: MyClass
def initialize(data: MyClass)
@data = data
end
end
which doesn't result in errors but produces a bad RBS file:
class My
@name: String
def initialize: (name: String) -> void
end
class MyOtherClass
@data: MyClass
def initialize: (data: MyClass) -> void
end
Though the ruby file is mostly-ish correct (except for unstripped types, which I saw in another issue)
class My::Class
attr_accessor :name: String
def initialize(name)
@name = name
end
end
class MyOtherClass
attr_accessor :data: MyClass
def initialize(data)
@data = data
end
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Backlog