Skip to content

Commit

Permalink
[Go] fix pipe after square brackets (#3908)
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall authored Jan 28, 2024
1 parent 1fe0b24 commit 9c5677c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
7 changes: 0 additions & 7 deletions Go/Go.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 28 additions & 1 deletion Go/tests/syntax_test_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 9c5677c

Please sign in to comment.