From 7c502f3da0ffe4c675a0ff8d76ecb21ca8dd380a Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 00:47:26 +0000 Subject: [PATCH] fix(loader): skip incomplete verb tables Co-Authored-By: Virgil --- loader.go | 3 +++ loader_test.go | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/loader.go b/loader.go index 96cf45f..fc6336d 100644 --- a/loader.go +++ b/loader.go @@ -132,6 +132,9 @@ func flattenWithGrammar(prefix string, data map[string]any, out map[string]Messa if gerund, ok := v["gerund"].(string); ok { forms.Gerund = gerund } + if forms.Past == "" || forms.Gerund == "" { + continue + } grammar.Verbs[core.Lower(verbName)] = forms continue } diff --git a/loader_test.go b/loader_test.go index 2cfa9bc..c2d3d86 100644 --- a/loader_test.go +++ b/loader_test.go @@ -132,6 +132,12 @@ func TestFlattenWithGrammar(t *testing.T) { "past": "tested", "gerund": "testing", }, + "partial_past": map[string]any{ + "past": "partialed", + }, + "partial_gerund": map[string]any{ + "gerund": "partialing", + }, "publish_draft": map[string]any{ "base": "publish", "past": "published", @@ -201,6 +207,18 @@ func TestFlattenWithGrammar(t *testing.T) { if _, ok := grammar.Verbs["publish_draft"]; ok { t.Error("verb should be stored under explicit base, not JSON key") } + if _, ok := grammar.Verbs["partial_past"]; ok { + t.Error("incomplete verb entry with only past should be skipped") + } + if _, ok := grammar.Verbs["partial_gerund"]; ok { + t.Error("incomplete verb entry with only gerund should be skipped") + } + if _, ok := messages["gram.verb.partial_past"]; ok { + t.Error("gram.verb.partial_past should not be flattened into messages") + } + if _, ok := messages["gram.verb.partial_gerund"]; ok { + t.Error("gram.verb.partial_gerund should not be flattened into messages") + } // Noun extracted if n, ok := grammar.Nouns["widget"]; !ok {