From 6d30f7b3327c0c02b4636cb7c475873b42ca49c4 Mon Sep 17 00:00:00 2001 From: Alexander Gall Date: Thu, 2 Jul 2026 16:42:05 +0200 Subject: [PATCH] lib.yang.schema: fix refinement of grouping instances When a grouping is applied with the "uses" statement, create copies of the grouped elements rather than references to them. This fixes the bug that a "refine" would otherwise modify the grouping itself rather than the instance at the place of insertion. --- src/lib/yang/schema.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/yang/schema.lua b/src/lib/yang/schema.lua index 3552da9dc7..7b292752f1 100644 --- a/src/lib/yang/schema.lua +++ b/src/lib/yang/schema.lua @@ -968,7 +968,8 @@ function resolve(schema, features) local grouping = lookup_lazy(env, 'groupings', v.id) for k,v in pairs(grouping.body) do assert(not node.body[k], 'duplicate identifier: '..k) - node.body[k] = v + -- Inline a copy for local refinements + node.body[k] = lib.deepcopy(v) end for _,refine in ipairs(v.refines) do local target = node.body[refine.node_id]