Handle `Struct.new`, `Data.define`, `Class.new` and `Module.new`
@vinistock is already working on this.
Since Jan 13, 2026.
- Dominant language
- Rust
- Stars
- 355
- Forks
- 24
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 17
Description
Putting all of these in the same issue as I suspect there'll be some shared logic. Using these methods return classes or modules and if we set those to a constant, they'll become a namespace where modules can be included, definitions can be created and so on.
In all cases where we write a constant, we need to check if the value is a new call node with a receiver of Struct, Class, Module (potentially OpenStruct too) and then create a class or module instead of a constant.
Important caveat: while invoking these methods does produce new classes and modules, they do not produce a new lexical scope like the class or module keyword. For example:
class Foo
Bar = Struct.new do
CONST = 123
end
end
The CONST definition here is Foo::CONST because Bar does not advance the lexical scope. In practical terms, it means we need to insert a ClassDefinition or ModuleDefinition in the graph, but we should not push anything to the definition stack.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.