From 6e7e077a8925da7a0a01a50a97233e119e8f5a19 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@lysator.liu.se>
Date: Wed, 20 Sep 2023 23:05:16 +0200
Subject: [PATCH] Minor cleanup for strings.

---
 muppet/puppet/format/parser.py | 12 ++----------
 tests/test_parse_elsif.py      |  4 ++++
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/muppet/puppet/format/parser.py b/muppet/puppet/format/parser.py
index c942ee8..1a960b8 100644
--- a/muppet/puppet/format/parser.py
+++ b/muppet/puppet/format/parser.py
@@ -370,16 +370,8 @@ class ParserFormatter(Serializer[ParseDirective]):
                          & optional(s('}')))
                     parser &= f
                 case PuppetString(st):
-                    # TODO what am I doing here? ParseError should
-                    # never be throw, since we aren't running the
-                    # parser, simply building it. And why is the
-                    # except block the exact same as the try block?
-                    try:
-                        for c in st:
-                            parser &= rich_char(c)
-                    except ParseError:
-                        for c in st:
-                            parser &= rich_char(c)
+                    for c in st:
+                        parser &= rich_char(c)
                 case _:
                     parser &= many(space) & "${" & ws & self.s(fragment) & ws & "}"
         parser &= s('"') & ws
diff --git a/tests/test_parse_elsif.py b/tests/test_parse_elsif.py
index db92640..cc02476 100644
--- a/tests/test_parse_elsif.py
+++ b/tests/test_parse_elsif.py
@@ -322,6 +322,10 @@ def test_string_interpolation_call_access():
                 block=None)]))
 
 
+def test_concat_with_actual_string():
+    parse_string('"Hello ${name}"')
+
+
 def test_collect():
     parse_string("""
     Exec <| title=='apt_update' |> {
-- 
GitLab