From 731752123d6e9fe2690f2937432007392b6724f0 Mon Sep 17 00:00:00 2001 From: Alfredo Beaumont Date: Wed, 6 Apr 2022 13:06:58 +0200 Subject: [PATCH] fix: resolve constants eagerly to avoid infinite loops. As the depedency graph may be cyclic. --- parser/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parser/types.go b/parser/types.go index 1111450..39fb5ef 100644 --- a/parser/types.go +++ b/parser/types.go @@ -130,6 +130,8 @@ func resolveConstants(classes ClassMap, cpools PoolMap, constants *[]constant, r if *resolved { return nil } + *constants = nil + *resolved = true for _, c := range *constants { if err := ResolveConstants(classes, cpools, int(c.classID)); err != nil { return fmt.Errorf("unable to resolve contants: %w", err) @@ -146,8 +148,6 @@ func resolveConstants(classes ClassMap, cpools PoolMap, constants *[]constant, r return fmt.Errorf("unable to resolve constants for field %s: %w", c.field, err) } } - *constants = nil - *resolved = true return nil }