From 571dbf92480a271fdb70cfb951321fe14c386ba4 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Fri, 17 May 2024 15:11:19 -0700 Subject: [PATCH] Test for block with top level comment after value parse Signed-off-by: Derek Collison --- conf/lex.go | 1 - conf/parse_test.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/conf/lex.go b/conf/lex.go index 43abdb728e..80a9a1147e 100644 --- a/conf/lex.go +++ b/conf/lex.go @@ -171,7 +171,6 @@ func (lx *lexer) emitString() { } else { finalString = lx.input[lx.start:lx.pos] } - // Position of string in line where it started. pos := lx.pos - lx.ilstart - len(finalString) lx.items <- item{itemString, finalString, lx.line, pos} diff --git a/conf/parse_test.go b/conf/parse_test.go index d74bc5612d..febb6082ef 100644 --- a/conf/parse_test.go +++ b/conf/parse_test.go @@ -812,6 +812,24 @@ func TestBlocks(t *testing.T) { }, "", "", }, + { + "comment in block scope after value parse", + ` + { + "debug": False + "server_name": "gcp-asianortheast3-natscj1-1" + + # Profile port specification. + "prof_port": 8221 + } + `, + map[string]any{ + "debug": false, + "prof_port": int64(8221), + "server_name": "gcp-asianortheast3-natscj1-1", + }, + "", "", + }, } { t.Run(test.name, func(t *testing.T) { f, err := os.CreateTemp(t.TempDir(), "nats.conf-")