[YANGTOOLS-603] Yang parser overwrites all multiple substatements with equal argument by the last one Created: 13/Apr/16  Updated: 10/Apr/22  Resolved: 18/Nov/16

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Peter Kajsa Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Blocks
is blocked by YANGTOOLS-628 Parser: Only the last prefix works if... Resolved
is blocked by YANGTOOLS-715 Parser: do not ignore SourceExceptions Resolved
External issue ID: 5717

 Description   

StatementContextBase.substatementBuilder(line 324) overwrites all multiple substatements with equal argument by the last one.



 Comments   
Comment by Suvitha Balu [ 19/May/16 ]

(In reply to Peter Kajsa from comment #0)
> StatementContextBase.substatementBuilder(line 324) overwrites all multiple
> substatements with equal argument by the last one.

Hi,
I am planning to work on this bug, could you please provide me more info.

Comment by Peter Kajsa [ 20/May/16 ]

Hi,

if a statement contains multiple substatements which have equal arguments, the previous are overwritten by the last one.

For an example, see bug https://bugs.opendaylight.org/show_bug.cgi?id=5396
where in
typedef my-type {
type union {
type string

{ pattern "dp[0-9]+o[0-9]+"; }

type string

{ pattern "dp[0-9]+s[0-9]+(f[0-9]+)?(d[0-9]+)?"; }

type string {
pattern "dp[0-9](P[0-9])?p[0-9]

{1,3}s[0-9]{1,3}

(f[0-9])?(d[0-9])?";
}
type string

{ pattern "dp[0-9]+p[0-9]+p[0-9]+"; }
}
}

the previous "type string" statements are overwritten by the last one:
type string { pattern "dp[0-9]+p[0-9]+p[0-9]+"; }

The same issue occurs also by multiple augment, refine, deviation,..?? statements.

These issues have been fixed by some hotfixes recently, but the root cause of the issue still persists. It is necessary to fix StatementContextBase.substatementBuilder in order to handle potential substatements in another way (for an example: track also the order of substatements and then check substatetement name, argument and also the substatement order).

Comment by Robert Varga [ 19/Oct/16 ]

This boils down to statements being in two classes:

  • attribute statements, which just add attributes to their enclosing entity
  • entity statements, which define an entity

The first type does not need an identifier, the second one does.

Comment by Robert Varga [ 11/Nov/16 ]

First step: eliminate substatement(), as it does not need to be visible: https://git.opendaylight.org/gerrit/48205

Comment by Robert Varga [ 11/Nov/16 ]

second step: use an integer to identify statements: https://git.opendaylight.org/gerrit/48241

Generated at Wed Feb 07 20:53:44 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.