diff --git a/CHANGELOG.md b/CHANGELOG.md
index 023024ed..9cf72fcf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -83,6 +83,7 @@ Developers may need to change their code
### Corrected Bugs
+* Fixed: [locally scoped YANG typedef in grouping does not work #394](https://github.com/clicon/clixon/issues/394)
* Fixed: [leafref in new type no work in union type](https://github.com/clicon/clixon/issues/388)
* Fixed: [must statement check int value failed](https://github.com/clicon/clixon/issues/386)
* Fixed: [Defaults in choice does not work properly](https://github.com/clicon/clixon/issues/390)
diff --git a/lib/src/clixon_yang_type.c b/lib/src/clixon_yang_type.c
index 60c596f2..47e2da93 100644
--- a/lib/src/clixon_yang_type.c
+++ b/lib/src/clixon_yang_type.c
@@ -1105,7 +1105,9 @@ static inline int
ys_typedef(yang_stmt *ys)
{
return yang_keyword_get(ys) == Y_MODULE || yang_keyword_get(ys) == Y_SUBMODULE ||
- yang_keyword_get(ys) == Y_CONTAINER || yang_keyword_get(ys) == Y_LIST;
+ yang_keyword_get(ys) == Y_CONTAINER || yang_keyword_get(ys) == Y_LIST ||
+ yang_keyword_get(ys) == Y_GROUPING
+ ;
}
/* find next ys up which can contain a typedef */
diff --git a/test/test_type.sh b/test/test_type.sh
index 2a495639..1e44983f 100755
--- a/test/test_type.sh
+++ b/test/test_type.sh
@@ -68,6 +68,19 @@ module example{
namespace "urn:example:clixon";
prefix ex;
import example2 { prefix ex2; }
+
+ grouping gt{
+ description "test of local scoped type as defined in RFC7950 Section 5.5";
+ typedef ag {
+ type string {
+ pattern
+ '(([c-g])\.){3}[c-g]';
+ }
+ }
+ leaf gr{
+ type ag;
+ }
+ }
typedef ab {
type string {
pattern
@@ -206,6 +219,7 @@ module example{
mandatory true;
}
}
+ uses gt;
}
EOF
@@ -624,6 +638,22 @@ EOF
new "netconf discard-changes"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" ""
+ #------ typedef scoped in grouping
+ new "type in grouping"
+ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "c.d.e.f" "" ""
+
+ new "validate grouping ok"
+ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" ""
+
+ new "type in grouping negatoive"
+ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "a.d.e.f" "" ""
+
+ new "validate grouping expect fail"
+ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-element"
+
+ new "netconf discard-changes"
+ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" ""
+
#------ minus
new "type with minus"