# Default-stmt can be ambiguous

**URL:** <https://dmap-community.ductus.global/t/default-stmt-can-be-ambiguous/1619>\
**Category:** YANG\
**Created:** [October 31, 2017, 8:54am UTC](https://dmap-community.ductus.global/t/default-stmt-can-be-ambiguous/1619 "2017-10-31T08:54:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukai](https://avatars.discourse-cdn.com/v4/letter/l/c2a13f/32.png) [@lukai](https://dmap-community.ductus.global/u/lukai)\
**Post date:** [October 31, 2017, 8:54am UTC](https://dmap-community.ductus.global/t/default-stmt-can-be-ambiguous/1619/1 "2017-10-31T08:54:02Z")

</div>

These two YANG “default” statements below are both acceptable to the ConfD.

```
  default 123;
  default "123";

```

I don’t know if quotes should be forbidden in default-stmt or not.  
But as the ABNF from RFC-6020 claims:

```
string = < an unquoted string, as returned by >
< the scanner, that matches the rule >
< yang-string >

```

I’ll treat unquoted string as the correct format.  
Then take this typedef-stmt for example.

```
typedef foo-type {
    type union {
        type string;
        type int32;
    }
    default 444;
}

```

From YANG grammar, I couldn’t tell what’s the actual type of default value “444”, it can be string, it also can be integer.

How does ConfD handle this?

---

<div class="post-metadata">

**Author:** ![per](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@per](https://dmap-community.ductus.global/u/per)\
**Post date:** [October 31, 2017, 1:51pm UTC](https://dmap-community.ductus.global/t/default-stmt-can-be-ambiguous/1619/2 "2017-10-31T13:51:00Z")

</div>

> [@lukai](#):
>
> These two YANG “default” statements below are both acceptable to the ConfD.
> 
> default 123;  
> default “123”;
> 
> I don’t know if quotes should be forbidden in default-stmt or not.

Both statements are valid, and there is no semantical difference between them. Quoting is required in the cases specified by [RFC 6020 - YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)](https://tools.ietf.org/html/rfc6020#section-6.1.3), otherwise optional.

> [@lukai](#):
>
> But as the ABNF from RFC-6020 claims:
> 
> string = \< an unquoted string, as returned by \>  
> \< the scanner, that matches the rule \>  
> \< yang-string \>

This means that the actual value is 123 - the quote characters are not part of the value.[quote=“lukai, post:1, topic:1619”]  
typedef foo-type {  
type union {  
type string;  
type int32;  
}  
default 444;  
}

From YANG grammar, I couldn’t tell what’s the actual type of default value “444”, it can be string, it also can be integer.  
[/quote]

From [RFC 6020 - YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)](https://tools.ietf.org/html/rfc6020#section-9.12)

```
   When a string representing a union data type is validated, the string
   is validated against each member type, in the order they are
   specified in the "type" statement, until a match is found.

```

Thus with that type definition, a default value will only ever match the string member, never int32. The corresponding text in [RFC 7950 - The YANG 1.1 Data Modeling Language](https://tools.ietf.org/html/rfc7950#section-9.12) is a little different, because it takes into consideration that in the JSON encoding, strings and integers have different representation, and it is thus possible for a value to match the int32 member, while for XML encoding, a value can only match the string member.
