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 3 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 31m 4s ⏱️
 3 021 tests  3 018 ✅   0 💤 3 ❌
55 878 runs  55 610 ✅ 264 💤 4 ❌

For more details on these failures, see this check.

Results for commit 17ceb67.

♻️ This comment has been updated with latest results.

vepadulano and others added 3 commits June 23, 2025 21:58
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, we now inject some logic to call `TClassTable::Check` earlier on
in the function, before the whitespace removal. This ensures that the name
lookup in the type system can work correctly. Note that a small addition
to the interface of TClingLookupHelper was needed, as the
`ExistingTypeCheck` method contains too much extra logic which in
certain situations would even lead to unwanted autoparsing if called too
early.

Co-authored-by: Philippe Canal <[email protected]>
The test is not available on Windows because the dictionary information is not
properly loaded in the same way as on other platforms. For now we keep the tests
disabled, considering that it won't affect ATLAS.
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