Skip to content

Commit 1c5a6a5

Browse files
authored
Merge pull request #133 from goccy/feature/fix-recursive-alias
Fix recursive alias in UnmarshalBytes
2 parents 24a3c7e + 597cf26 commit 1c5a6a5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

decode.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func (d *Decoder) resolveAlias(node ast.Node) ast.Node {
238238
}
239239
case *ast.AliasNode:
240240
aliasName := n.Value.GetToken().Value
241-
return d.anchorNodeMap[aliasName]
241+
return d.resolveAlias(d.anchorNodeMap[aliasName])
242242
}
243243
return node
244244
}

decode_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,7 @@ anchors:
19051905
map: &y
19061906
a: b
19071907
c: d
1908+
d: *x
19081909
a: *x
19091910
b:
19101911
<<: *y
@@ -1920,7 +1921,16 @@ b:
19201921
if v.A != "hello" {
19211922
t.Fatal("failed to unmarshal with alias")
19221923
}
1923-
if len(v.B) != 3 {
1924+
if len(v.B) != 4 {
1925+
t.Fatal("failed to unmarshal with alias")
1926+
}
1927+
if v.B["a"] != "b" {
1928+
t.Fatal("failed to unmarshal with alias")
1929+
}
1930+
if v.B["c"] != "d" {
1931+
t.Fatal("failed to unmarshal with alias")
1932+
}
1933+
if v.B["d"] != "hello" {
19241934
t.Fatal("failed to unmarshal with alias")
19251935
}
19261936
}

0 commit comments

Comments
 (0)