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

Node Ancestry Should be Considered for Node Type Restrictions in PROTOs #6573

Open
CoolSpy3 opened this issue Jul 2, 2024 · 1 comment · Fixed by #6574
Open

Node Ancestry Should be Considered for Node Type Restrictions in PROTOs #6573

CoolSpy3 opened this issue Jul 2, 2024 · 1 comment · Fixed by #6574

Comments

@CoolSpy3
Copy link
Contributor

CoolSpy3 commented Jul 2, 2024

Describe the Bug
At the moment, Node fields in PROTOs are required to list every type which they can accept (if they are type restricted). However, this us true even if all of the necessary types share a common base type which would be sufficient. This leads to verbose type restrictions where only a single actual type is required, and is unintuitive given the inheritance-style structure of nodes.

Steps to Reproduce
Attempt to load the PROTOs:

# Base.proto
#VRML_SIM R2023b utf8

PROTO Base [] { Pose {} }
# ExtendsBase.proto
#VRML_SIM R2023b utf8

EXTERNPROTO "../protos/Base.proto"

PROTO ExtendsBase [] { Base {} }
# Example.proto
#VRML_SIM R2023b utf8

EXTERNPROTO "../protos/Base.proto"
EXTERNPROTO "../protos/ExtendsBase.proto"

PROTO Example [
    unconnectedField MFNode{Base{},Solid{}} f [ExtendsBase{},LightSensor{}]
]
{ Pose {} }

When trying to load Example.proto, Webots will state that the default values of f are not permitted even though ExtendsBase is an instance of Base, and LightSensor is an instance of Solid.

Expected behavior
The entire ancestry of nodes should be considered when determining if they satisfy a node restriction. This would make the above code valid.

System

  • Operating System: Windows 10
  • Graphics Card: NVIDIA GeForce 1050 Ti
@omichel
Copy link
Member

omichel commented Jul 2, 2024

That sounds like a good idea. Please go ahead with the implementation and open a new PR to propose your contribution. We will review it and likely accept it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants