From 9c5677c03424b644a107a99ac1e2f34008f42105 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Sun, 28 Jan 2024 19:27:08 +0200 Subject: [PATCH] [Go] fix pipe after square brackets (#3908) --- Go/Go.sublime-syntax | 7 ------- Go/tests/syntax_test_go.go | 29 ++++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Go/Go.sublime-syntax b/Go/Go.sublime-syntax index 80707c3444..06a66d989e 100644 --- a/Go/Go.sublime-syntax +++ b/Go/Go.sublime-syntax @@ -531,15 +531,8 @@ contexts: - include: pop-on-bracket-end - include: match-any - # Known bug: - # - # _ = ident[0] * ident - # - # This currently parses as an array type of `[0]*ident`. - # Can we ever fix this false positive? pop-after-brackets: - include: pop-before-terminator - - include: match-type-operators - include: pop-type-identifier # TODO: consider detecting composite literals. In principle, it should allow diff --git a/Go/tests/syntax_test_go.go b/Go/tests/syntax_test_go.go index b0ba238d7f..62cd186e15 100644 --- a/Go/tests/syntax_test_go.go +++ b/Go/tests/syntax_test_go.go @@ -5858,9 +5858,36 @@ func lang_embedding() { // language=sql some_func_call( args_on_next_line, ` - SELECT min(a) + SELECT min(a) FROM b WHERE c = @p1`, "some value", // ^^^^^^^^^^^^^^ meta.string.go meta.embedded.go source.sql.embedded.go ) // <- punctuation.section.parens.end.go - invalid + +_ = ident[0] * ident +// ^^^^^ variable.other +// ^ punctuation.section.brackets.begin +// ^ meta.number.integer.decimal constant.numeric.value +// ^ punctuation.section.brackets.end +// ^ keyword.operator +// ^^^^^ variable.other +func sth() { + + a := 123 + data := []int + + b := 0 + b = data[b]|a +// ^ keyword.operator.bitwise +// ^ variable.other + b = data[b]^a +// ^ keyword.operator.bitwise +// ^ variable.other + b = data[b]&a +// ^ keyword.operator +// ^ variable.other + b = b|a +// ^ keyword.operator.bitwise +// ^ variable.other +}