Skip to content

Check for existing type before removing whitespaces #19087

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

vepadulano
Copy link
Member

Fixes #19022

See first commit description for an explanation.

Third commit provides a reproducer of the linked issue, removing the first commit will produce the same exception from RField

Copy link
Contributor

@jblomer jblomer left a comment

Choose a reason for hiding this comment

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

Good work! (Still an issue with the new test to be fixed)

Copy link

github-actions bot commented Jun 18, 2025

Test Results

    19 files      19 suites   3d 16h 57m 47s ⏱️
 3 021 tests  3 018 ✅   0 💤 3 ❌
55 878 runs  55 608 ✅ 264 💤 6 ❌

For more details on these failures, see this check.

Results for commit 17ceb67.

♻️ This comment has been updated with latest results.

@vepadulano vepadulano force-pushed the gh-19022 branch 3 times, most recently from a489091 to 4042668 Compare June 19, 2025 13:54
@vepadulano vepadulano requested a review from martamaja10 as a code owner June 19, 2025 13:54
vepadulano and others added 6 commits June 20, 2025 10:08
This fixes root-project#19022

In `TClassEdit::GetNormalizedName`, the call to
`gInterpreterHelper->ExistingTypeCheck` is the one where eventually any
alternative names for the class name being looked for will be detected and used
for replacement (in `TClassTable::Check`). The alternative names for a custom
class may appear in a dictionary when the user declared their class in the
`ROOT::Meta::Selection` namespace and made it derive from the
`KeepFirstTemplateArguments` type trait.

Previously, the call to `ExistingTypeCheck` only happened after the input
demangled type name passed through the normalization logic of
`TClassEdit::TSplitType`. This led to an unfortunate situation.

The demangled type name resulting from a previous `TClassEdit::DemangleName`
call is the name representation of the typeid of the class type for the current
execution, i.e. whatever was generate by the compiler. In the case of a class
with multiple template arguments, this usually leads to a representation of the
form `A<B, C>`, i.e. where the two template arguments are separated by a
whitespace after the comma.

Crucially, this representation is also the same one used by the type system to
populate the dictionary information relative to the alternative class name for
classes where the user wants to strip one or more template arguments. In the
example just made, the class alternative name for `A<B>` will be registered as
`A<B, C>` with the whitespace in the dictionary sources.

Since the call to `ExistingTypeCheck` was happening *after* the `TSplitType`
normalization, the input class name was lacking the extra whitespace. Thus, any
search in `TClassTable::Check` would fail because it does a hash-based lookup of
the string in the map of class alternatives.

Thus, this commit introduces a second call to `ExistingTypeCheck` earlier on in
the function, before the removal of the whitespace. This ensures that the name
lookup in the type system can work correctly.

Co-authored-by: Philippe Canal <pcanal@fnal.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can not access REntry fields with DataVector in python
2 participants