Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions JuliaSyntax/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# JuliaSyntax Agent Instructions

See [../AGENTS.md](../AGENTS.md) for general instructions.

## Parser changes

When modifying the parser, always verify that AST production comments (e.g., `# f.[x] ==> (error f x)`) accurately reflect the actual parser output.
1 change: 1 addition & 0 deletions JuliaSyntax/CLAUDE.md
8 changes: 8 additions & 0 deletions JuliaSyntax/src/julia/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,14 @@ function parse_call_chain(ps::ParseState, mark, is_macrocall=false)
emit(ps, emark, K"error",
error="the .' operator for transpose is discontinued")
emit(ps, mark, K"dotcall", POSTFIX_OP_FLAG)
elseif k == K"[" || k == K"{"
# f.[x] ==> (error f x)
# f.{x} ==> (error f x)
# Parse as broadcasted brackets, then wrap in error
close = k == K"[" ? K"]" : K"}"
bump(ps, TRIVIA_FLAG)
parse_cat(ParseState(ps, end_symbol=true), close, ps.end_symbol)
emit(ps, mark, K"error", error="brackets are not allowed after `.`")
else
if saw_misplaced_atsym
# If we saw a misplaced `@` earlier, this might be the place
Expand Down
4 changes: 4 additions & 0 deletions JuliaSyntax/test/diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ end
Diagnostic(3, 4, :error, "`@` must appear on first or last macro name component")
@test diagnostic("@M.(x)") ==
Diagnostic(1, 3, :error, "dot call syntax not supported for macros")
@test diagnostic("a.[x]") ==
Diagnostic(1, 5, :error, "brackets are not allowed after `.`")
@test diagnostic("a.{x}") ==
Diagnostic(1, 5, :error, "brackets are not allowed after `.`")

@test diagnostic("try x end") ==
Diagnostic(1, 9, :error, "try without catch or finally")
Expand Down
4 changes: 2 additions & 2 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,8 @@ g21054(>:) = >:2
@test g21054(-) == -2

# issue #21168
@test_broken Meta.lower(Main, :(a.[1])) == Expr(:error, "invalid syntax \"a.[1]\"")
@test_broken Meta.lower(Main, :(a.{1})) == Expr(:error, "invalid syntax \"a.{1}\"")
@test_parseerror "a.[1]"
@test_parseerror "a.{1}"

# Issue #21225
let abstr = Meta.parse("abstract type X end")
Expand Down