Skip to content

Accept leading :: in Graph#[] lookups#814

Merged
st0012 merged 5 commits into
Shopify:mainfrom
truffle-dev:fix-graph-aref-leading-double-colon
Jul 6, 2026
Merged

Accept leading :: in Graph#[] lookups#814
st0012 merged 5 commits into
Shopify:mainfrom
truffle-dev:fix-graph-aref-leading-double-colon

Conversation

@truffle-dev

Copy link
Copy Markdown
Contributor

Closes #813

Rubydex::Graph.new["::Object"] returned nil because the FFI lookup hashed the input string verbatim, while declarations are keyed on the unqualified name (e.g. DeclarationId::from("Object") in built_in.rs). The two affected entry points are Graph::get and the FFI rdx_graph_get_declaration that Graph#[] forwards through.

Stripping an optional leading :: at both lookup sites lets the root-scope marker resolve to the same declaration as the bare name, matching the way nested constants like Thread::Backtrace already work. Added a Rust unit test covering built-ins, top-level, nested, and unknown-name cases, plus a Ruby integration test that exercises the full FFI path.

This is the lookup quirk koic hit in the Rubydex/RuboCop integration.

@truffle-dev
truffle-dev requested a review from a team as a code owner May 20, 2026 02:32
@truffle-dev

Copy link
Copy Markdown
Contributor Author

Friendly check-in on this one. It's a small surgical fix (strip an optional leading :: at the two lookup entry points, with a regression test for Graph#["::Object"]), still clean against main and closing #813. Happy to rebase or adjust if anything would help it land.

@truffle-dev

Copy link
Copy Markdown
Contributor Author

Closing this for now. The fix is small (accept an optional leading :: at the two Graph#[] entry points, with a regression test for Graph#["::Object"]), but it has sat CLA-blocked for a month with no review, and signing the full Shopify CLA is a heavy lift for a one-line lookup change. Happy to reopen and sort the CLA if a maintainer wants it. Thanks.

@rafaelfranca

Copy link
Copy Markdown
Member

Sorry about that. We didn't review because the CLA was needing to be signed, but the change looks ok. I'll happily merge if the CLA is signed.

@github-actions

Copy link
Copy Markdown
Contributor

CLA: Unexpected error has occurred, please re-run the workflow.

We are sorry for the inconvenience, due to GitHub actions limitations this requires a manual intervention.

There are few ways to do it:

  • Create a new pull request with the same changes.
  • Push an empty commit to the branch.
  • Rebase the branch on top of the latest master might also help.

If the issue persists, please contact the maintainers of this repo.

@truffle-dev truffle-dev reopened this Jun 26, 2026
@truffle-dev

Copy link
Copy Markdown
Contributor Author

Sorry about that. We didn't review because the CLA was needing to be signed, but the change looks ok. I'll happily merge if the CLA is signed.

CLA has been signed already. Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

CLA: Unexpected error has occurred, please re-run the workflow.

We are sorry for the inconvenience, due to GitHub actions limitations this requires a manual intervention.

There are few ways to do it:

  • Create a new pull request with the same changes.
  • Push an empty commit to the branch.
  • Rebase the branch on top of the latest master might also help.

If the issue persists, please contact the maintainers of this repo.

`Rubydex::Graph.new["::Object"]` returned `nil` because the FFI lookup
hashed the string verbatim, while the stored declaration is keyed on
the unqualified name. Strip an optional leading `::` at the lookup
boundary in both `Graph::get` and `rdx_graph_get_declaration` so the
root-scope marker resolves to the same declaration as the bare name.

Fixes Shopify#813
@truffle-dev
truffle-dev force-pushed the fix-graph-aref-leading-double-colon branch from e9b2d4f to 0cf7dd3 Compare June 27, 2026 03:06
@truffle-dev

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main per the bot's hint, and that cleared the stuck CLA workflow. The cla check is green now. Ready whenever you are.

By moving the logic for stripping the leading `::` root-scope marker
into a single function, we ensure that all declaration name lookups are
normalized consistently. This prevents potential mismatches when looking
up declarations with or without the leading `::`.
We don't define functions on type aliases for the `DefinitionId`, so
let's not define a function on the `DeclarationId` type alias either.

@st0012 st0012 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@st0012 st0012 added the bugfix A change that fixes an existing bug label Jul 6, 2026
@st0012
st0012 merged commit dacd072 into Shopify:main Jul 6, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix A change that fixes an existing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support look ups with fully-qualified constant names

3 participants