Open
Conversation
d2bbdda to
78f9340
Compare
Morriar
requested changes
Jan 19, 2026
Contributor
Morriar
left a comment
There was a problem hiding this comment.
I don't think this is the right direction, we're trying to work around a huge limitation in the design.
We discovered that we need to be able to encode the fact one definition can lead to multiple declaration: module_function, attr_accessor, attr, and most likely a lot of DSLs (AASM, AcvtiveRecord, StateMachine, etc.).
This invalidate the N:1 definitions:declaration principle we though would work and I think we need to address the fundamental issue rather than introducing hacks.
Contributor
|
Following #485, it also looks like this: Foo = Struct.new("Bar")Creates 2 declarations: the struct under |
vinistock
added a commit
that referenced
this pull request
Jan 19, 2026
Closes #128 I added a test to verify that all fully qualified names we generate are what we expect. All of them were already correct, with two exceptions: - Attributes. We're not generating the methods related to attributes yet (proposal in #471) - Global variables. This is fixed in this PR and there's a slight caveat. I changed the fully qualified to be just the global variable name, but I kept the owner as `Object`. I believe this is fine for now, but we may want to revisit later. Global variables are accessible everywhere, so maybe for completion/go to definition algorithms, it will make more sense to place it in `BasicObject`? Or perhaps we need the magic `<main>`? I'll leave that to a dedicated PR
78f9340 to
6fac261
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
This PR is a proposal to change how we handle attributes. Right now, we have distinct definition types for each one. In reality, they are methods and all we're interested in remembering is how they were originally defined.
I think we can simplify our code by quite a bit if we just use bitflags to remember how they were originally defined and reuse the
MethodDefinitionstruct to represent them.The main goal is also to handle attributes correctly without incurring more memory cost. An
attr_accessorcall should result in 2 declarations. We currently have only one definition created, which means that ourdefinitions_to_declarationsconnection fails to model it. Similar issue that we discovered when working onmodule_function.I don't believe we should change the
definitions_to_declarationsmap to store vectors as that will change the size of the values from 2 bytes to vector size + 2 bytes.Another added benefit, although a lot less important, is that by handling attributes as methods we might also be able to correctly handle the receiver. For example, in a case like this:
We'd just model it exactly like a method receiver and then in resolution we decide if we go into the singleton level or not based on whether it's a method or an attribute.
Implementation
I added all attribute types as flags, removed all attribute definitions and fixed all of the code I could find.