Skip to content

use loneElement instead of onlyChecked#5585

Merged
mpollmeier merged 7 commits intomasterfrom
michael/lone-element
Jul 12, 2025
Merged

use loneElement instead of onlyChecked#5585
mpollmeier merged 7 commits intomasterfrom
michael/lone-element

Conversation

@mpollmeier
Copy link
Contributor

No description provided.

@mpollmeier mpollmeier requested a review from maltek July 11, 2025 13:11
Copy link
Contributor

@maltek maltek left a comment

Choose a reason for hiding this comment

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

didn't you just add a new message argument, to make errors from missing edges easier to understand?

@mpollmeier
Copy link
Contributor Author

good point :)

@mpollmeier mpollmeier force-pushed the michael/lone-element branch from 15417d9 to 3436c06 Compare July 11, 2025 13:34
@mpollmeier
Copy link
Contributor Author

while writing the hints, i noticed that something like AstNode.astParentOption would be useful and I added that... would you agree?

@maltek
Copy link
Contributor

maltek commented Jul 11, 2025

while writing the hints, i noticed that something like AstNode.astParentOption would be useful and I added that... would you agree?

it is technically more correct - there are roots that just don't have a parent. IME it's rare to accidentally run into that, except with frontend bugs where crashing loudly is likely the best course of action. Usually you know where you want to go in the AST and stop long before you reach a File node. But overall it's probably good to have it there.

@mpollmeier
Copy link
Contributor Author

ok, I guess it doesn't harm, so let's keep it there then

@mpollmeier
Copy link
Contributor Author

The semantic change of loneElement to also error if there's more than one rather than just issuing a warning just uncovered that kotlin2cpg creates duplicate ast edges in some cases. Will create a separate ticket for that.

The error message Iterable was expected to have exactly one element, but it has 1 is obviously wrong - that's fixed in joernio/flatgraph#340

@mpollmeier
Copy link
Contributor Author

kotlin2cpg is already fixed in #5587 - will await the merge and rebase then

@mpollmeier mpollmeier force-pushed the michael/lone-element branch from fca3564 to 3383127 Compare July 11, 2025 18:18
@mpollmeier mpollmeier merged commit d995936 into master Jul 12, 2025
8 checks passed
@maltek maltek deleted the michael/lone-element branch July 14, 2025 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants