Skip to content
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

Fix for Issue #104 #107

Merged
merged 3 commits into from
Jul 16, 2024
Merged

Fix for Issue #104 #107

merged 3 commits into from
Jul 16, 2024

Conversation

thirtytwobits
Copy link
Member

This changes our logic for detecting duplicate definitions on case-sensitive file-systems to only operate on files of interest and to fix this detection logic per issue #104.

If globular searches find duplicates we do not waste time detecting this until/unless these duplicates are actually considered when parsing target definitions.

This changes our logic for detecting duplicate definitions on case-sensitive file-systems to only operate on files of interest and to fix this detection logic per issue OpenCyphal#104.

If globular searches find duplicates we do not waste time detecting this until/unless these duplicates are actually considered when parsing target definitions.
found = list(filter(lambda d: d.full_name == full_name and d.version == version, self._lookup_definitions))
found = list(
filter(
lambda d: d.full_name.lower() == full_name.lower() and d.version == version, self._lookup_definitions
Copy link
Member

Choose a reason for hiding this comment

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

This seems to make the search case-insensitive, why? In the Spec we state that identifiers are case-sensitive, but it is still considered a collision if identifiers differ by letter case only. Does this change allow the following:

# Foo.1.0.dsdl
bar.1.0 bar  # Will "bar.1.0" name "Bar.1.0"?
@sealed
# Bar.1.0.dsdl
@sealed

If yes, then it seems to be a problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since Bar.1.0.dsdl and bar.1.0.dsdl will both be accepted by this filter the later logic that requires only 1 result will raise the appropriate collision exception.

Copy link
Member

Choose a reason for hiding this comment

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

Okay but I'm not talking about collisions here, but rather the selectivity of the search. If I only have Bar.1.0.dsdl and I can name it bar.1.0.dsdl, we have a problem, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

You don't if only 1 dsdl file is found. If two are found then it is a collision caused either by case-sensitivity issues or by multiple paths to the same definition in different files. So selectivity doesn't matter since we never select one of multiple values returned from this filter.

Copy link
Member Author

Choose a reason for hiding this comment

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

ping?

Copy link
Member

@pavel-kirienko pavel-kirienko Jul 8, 2024

Choose a reason for hiding this comment

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

This behavior is not spec-conformant. I understand that collision is a non-issue and am, in fact, talking about a completely different issue here: if the case doesn't match, the search should return nothing.

image

@pavel-kirienko pavel-kirienko mentioned this pull request Jun 29, 2024
Copy link
Member

@pavel-kirienko pavel-kirienko left a comment

Choose a reason for hiding this comment

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

Can we please extend the test for issue 104 with another definition that contains the following field definition and ensure that it fails to parse:

a.b.thing.Thingtype.1.0 thing

Promoting case-sensitivity issue from assertion error to DataTypeNameCollisionError
@thirtytwobits
Copy link
Member Author

We good now?

@thirtytwobits
Copy link
Member Author

Ping? I have another PR parked behind this one too.

pydsdl/_data_type_builder.py Outdated Show resolved Hide resolved
@pavel-kirienko
Copy link
Member

Apologies for the delay, things pile up.

@thirtytwobits thirtytwobits merged commit c0afc34 into OpenCyphal:master Jul 16, 2024
13 checks passed
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