Shopify / Shopify/rubydex

Handle `Struct.new`, `Data.define`, `Class.new` and `Module.new`

Open
#392 1 comment 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.