What is the proposed solution for error "the same code-name must be assigned to all identifiers with the same name"

Hi,

We are migrating from ConfD 5.0 to 6.4.3 and while compiling my yang file it gives error “The node ‘umts’ and the node ‘umts’ (at myYangFile.yang) have been assigned different code-names. When tailf:code-name is used, the same code-name must be assigned to all identifiers with the same name.”

Actually, in my case. first container name is umts and leaf node which is part of second container has its name as umts. Isn’t it like two different nodes which are not part of each other can have same name?

Whats is the approach to be followed to get rid of this error? It was compiling successful in ConfD 5.0

container umts {
description “UMTS profiles.”;

         leaf access-mode {
                description "The type of access mode";
                type enumeration {
                    enum open {tailf:code-name "accessmode-local"; value 0;}
                    enum closed {tailf:code-name "accessmode-closed";}
                    enum hybrid {tailf:code-name "accessmode-hybrid";}
                }
                default open;                    
            }

       leaf access-decision {
                description "The access decision ";
                type enumeration {
                    enum local {tailf:code-name "accessdecision-local";value 0;}
                    enum query {tailf:code-name "accessdecision-query";}
                    enum byCore {tailf:code-name "accessdecision-bycore";}
                }
                default query;                    
            }
 }

container statistics {
description “statistics profiles.”;

        leaf umts{
                description "UMTS statistics";
                type uint8 {
                    range "0|1..60";
                }
                tailf:code-name "cws-umts-stats";
                default 15;
            }
 }

Thanks in advance.

Of course they can have the same name (even if one is part of the other) - but you can’t have different tailf:code-name assignments for them. I.e. in this case “cws-umts-stats” for one of them, and none for the other.[quote=“bsomani, post:1, topic:1587”]
Whats is the approach to be followed to get rid of this error?
[/quote]
Well, the question is why you are using tailf:code-name at all? But in any case, you need to either remove the tailf:code-name statement for the leaf, or add an identical statement for the container.[quote=“bsomani, post:1, topic:1587”]
It was compiling successful in ConfD 5.0
[/quote]
Yes, this was a bug - from the ConfD-5.4 CHANGES file:

  - Toolchain: The tailf:code-name statement can not be used to assign
    different code-names to different nodes with a given name, or assign a
    code-name to only some nodes with a given name. The confdc --emit-xxx
    operation would in such cases silently use one code-name assignment for
    all the same-named nodes. This has been fixed - such inconsistent usage
    of tailf:code-name will now result in a compilation error.

I.e. in your case you got (for the file generated by ‘confdc --emit-h’):

#define <prefix>_cws_umts_stats 1128642429

and no #define for “umts”.

The problem with this is that you may have assumed that you could differentiate between the container and the leaf based on the code-name, and expected case <prefix>_cws_umts_stats: in a switch statement to only match the leaf - but this is not the case, since they have the same integer value regardless of code-name, and you would get incorrect behavior at runtime when it actually matched the container.