-
Notifications
You must be signed in to change notification settings - Fork 333
Call nodes: App tree roots
#14303
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
base: develop
Are you sure you want to change the base?
Call nodes: App tree roots
#14303
Conversation
3de84c1 to
861b902
Compare
ff69db1 to
42096c9
Compare
| @Test | ||
| public void callingExtensionMethodDefinedElsewhere() throws Exception { | ||
| final URI uriA = new URI("memory://local.Project1.modA.enso"); | ||
| final URI uriA = new URI("memory://local.Project1.Mod_A.enso"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original was not a valid module name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- introduced by Infer method calls on known types and warn about nonexistent methods #11399
- OK to change
farmaazon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving parser&GUI
lib/rust/parser/src/lib.rs
Outdated
| if let Variant::Eval(eval) = &tree.variant | ||
| && matches!(&eval.value.variant, Variant::Ident(_) | Variant::PropertyAccess(_)) | ||
| { | ||
| let Tree { variant: Variant::Eval(mut eval), span, .. } = tree else { unreachable!() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it possible to make this let inside if condition in place of let Variant::Eval(eval) = &tree.variant? Also, I'm not sure, but perhaps making && matches! in if a where clause in match may look better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the unsafe borrow-to-owned upgrade pattern is unavoidable in this case, unless we refactor the whole thing to a mutable-borrow solution (but that tends to require allocations that wouldn't be necessary in this approach).
In order to tell if ownership should be taken, we must look inside the variant; sometimes a deep pattern can take ownership while checking the variant simultaneously, but that isn't possible here because the variant is boxed and box patterns aren't available in Rust as of our current version.
I will think about whether I can encapsulate the borrow-inspect-upgrade pattern for tree variant operations, to contain the unsafety to one function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, in this case I can take ownership unconditionally, then if the validity check fails I can return an error explicitly rather than falling through to the general error case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I looked for is code simplification; if it would required "unsafe" operations, then it is not worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I shouldn't have said unsafe, I meant "requiring an unreachable branch", which could be unsafe but in this case is handled by a panic. Anyway, I've eliminated the panic branch with some ownership wrangling.
| /// Wraps a value, tracking the number of wildcards operands within it. | ||
| #[derive(Default, Debug, PartialEq, Eq)] | ||
| pub struct Operand<'s> { | ||
| pub value: Tree<'s>, | ||
| pub wildcards: bool, | ||
| pub eval: bool, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs says about tracking number of wildcards, but field has bool only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the next step is to use it to replace some analysis on both sides.
- May I get some explanation why this change is needed?
- I don't see any reason to introduce
Tree.Evalfrom engine perspective- we already have EvalNode!
- I don't understand why it should be needed by the IDE
- may some documentation be updated to provide some high level perspective
- and justify the change?
|
Yeah, I'm debugging this. Probably a missed case in |
This reverts commit 41dbdd7.
|
Making some changes to the treatment of PropertyAccess (thanks to @JaroslavTulach's feedback in enso-org/design/pull/60#discussion_r2587629509). I'm disabling adding the new nodes to PropertyAccess/Ident to get the bulk of the changes merged while I work on the new PropertyAccess logic. |
Pull Request Description
Add new
Callnode at the root of app/named-app calls; the next PR will enable the nodes at the sites of possible no-argument calls (i.e. around Ident and PropertyAccess nodes). For now node is ignored in backend and frontend; the next step is to use it to replace some analysis on both sides.See: https://github.com/enso-org/design/pull/60
Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.