-
-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactorings working towards nested destructuring #428
Refactorings working towards nested destructuring #428
Conversation
First of all thanks for putting your time in Mint! I really appriciate it 🙏 Also thank you for creating these detailed PRs 👍 they help a lot!
That module is responsible for keeping track of the entities which are in scope. It's like a stack, for example given this code:
the scope when resolving the body of the
when trying to resolve the call to In this case it will try to find It has code for tuple destructuring because they can be used in statements where array and enum cannot, now that we are trying to do nested destructurings maybe it would be good do the matching here instead of the case branch by hand (let me know if doesn't make sense and I'll try to explain it further).
Yeah, I struggle with it some times, Crystal does not use aliases when an error happens as it would be a partial solution at least but I can understand that how difficult to achieve that. I'll try to add return types in the future. If you need any at the moment let me know and we'll add them.
It's possible I guess, I'm not sure how to do it though as it would require extracting command line arguments from the spec command somehow, maybe @Sija has some ideas :D
I guess that's fair, It's on me and I need to get better at it. If you have examples in other projects where its done right that would help me a lot in the future. Until then ask away and I'll answer and document along the way (probably on Discord or some other channel). In this specific case the |
@matthewmcgarvey Please rebase on top of the current |
5cc981f
to
63f0cac
Compare
Prepare for extra code to extract variables and recurse
63f0cac
to
f079ff0
Compare
@gdotdesign will this be merged or do you want me to keep committing to it? |
I'll merge it, I was just waiting for your input 🙂 |
Related to #226
I don't want to drop a 1000-2000 PR, and I already have some questions so might as well pull out as much refactoring code as makes sense at this point.
A lot of this was pulled from #283 as I have been learning why it was written the way it was.
Hopefully these are good enough refactorings on their own aside from preparing for nested destructuring.
Changes
type_checkers/case_branch.cr
since it will be moved to recursion to get nested variablesAst::EnumDestructuring
,Ast::TupleDestructuring
, andAst::ArrayDestructuring
all have parameters as[] of Ast::Node
since they will hold more than one type for destructuring_compile
methods for the destructurings as they will also have a recursive aspect for destructuringsQuestions
type_checkers/scope.cr
I'm not sure what that is doing and how that will support destructurings going forward. Is selecting only variables good enough? I'll have to dig into nested's once they're added I suppose?type_checkers/case_branch.cr
does type checking. It kind of looks liketype_checkers/case.cr
is doing some Tuple counting. Is there a way we could refactor (if that is type checking) to a place where they could be called for nested destructurings?Current Struggles
This is my first time working in Mint's compilers so everything's kind of new. Apart from that, some things that have caused me a hard time:
condition
here? I've just been ignoring anything I don't understand