From a9d7525dd6d7fd93875e1c36c50f43d6dec54c3e Mon Sep 17 00:00:00 2001 From: Spencer Brower <6729162+sbrow@users.noreply.github.com> Date: Mon, 10 Aug 2026 17:36:32 -0400 Subject: [PATCH] fix: Empty tags now report diagnostics. --- DIAGNOSTIC_TESTS.yaml | 15 ++++++++++++++- mustache/diagnostic_test_cases_test.odin | 5 +++++ mustache/mustache.odin | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/DIAGNOSTIC_TESTS.yaml b/DIAGNOSTIC_TESTS.yaml index 6a94fc0..2e87721 100644 --- a/DIAGNOSTIC_TESTS.yaml +++ b/DIAGNOSTIC_TESTS.yaml @@ -130,7 +130,7 @@ input: | expected: | Empty tag - --> :11:28 + --> :11:28 | 9 | href="https://edwardtufte.github.io/tufte-css/">Tufte CSS 10 |

@@ -139,6 +139,19 @@ expected: | 12 | | --- +name: empty raw tag +enable: true +should: error +input: | + Hello, {{&}} +expected: | + Empty tag + --> :1:8 + | + 1 | Hello, {{&}} + | ^^^^^ tag must contain a key + | +--- name: Missing pipe arguement enable: true should: error diff --git a/mustache/diagnostic_test_cases_test.odin b/mustache/diagnostic_test_cases_test.odin index ad83795..fb39626 100644 --- a/mustache/diagnostic_test_cases_test.odin +++ b/mustache/diagnostic_test_cases_test.odin @@ -28,6 +28,11 @@ test_diag_empty_tag :: proc(t: ^testing.T) { run_diag_case(t, "empty tag") } +@(test) +test_diag_empty_raw_tag :: proc(t: ^testing.T) { + run_diag_case(t, "empty raw tag") +} + @(test) test_diag_missing_pipe_arguement :: proc(t: ^testing.T) { run_diag_case(t, "Missing pipe arguement") diff --git a/mustache/mustache.odin b/mustache/mustache.odin index 86b0482..ce18864 100644 --- a/mustache/mustache.odin +++ b/mustache/mustache.odin @@ -271,6 +271,14 @@ parse_section :: proc( pos^ += 1 case .Variable: + if len(strings.trim_space(tok.value)) == 0 { + return Error_Body { + msg = "Empty tag", + pos = tok.pos, + kind = .Syntax, + hint = "tag must contain a key", + } + } idx := len(nodes) append(nodes, Node{kind = .Variable}) pipe_key, perr := parse_pipeline( @@ -290,6 +298,14 @@ parse_section :: proc( pos^ += 1 case .Unescaped: + if len(strings.trim_space(tok.value)) == 0 { + return Error_Body { + msg = "Empty tag", + pos = tok.pos, + kind = .Syntax, + hint = "tag must contain a key", + } + } idx := len(nodes) append(nodes, Node{kind = .Unescaped}) pipe_key, perr := parse_pipeline(