Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into node-c…
Browse files Browse the repository at this point in the history
…loning
  • Loading branch information
T14Raptor committed Oct 20, 2024
2 parents cd8708f + ca5e2ec commit f6d634d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/generate_visit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Generate visit.go

on:
push:
paths:
- 'ast/**'
- '!ast/visit.go'
workflow_dispatch:

jobs:
generate-visit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Generate visit.go
run: go run ast/gen_visit.go

- name: Check for changes
id: git-check
run: |
git diff --exit-code ast/visit.go || echo "changes=true" >> $GITHUB_OUTPUT
- name: Commit changes
if: steps.git-check.outputs.changes == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add ast/visit.go
git commit -m "Auto-generate visit.go"
git push
4 changes: 2 additions & 2 deletions ast/ident.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ type (
func (n *Identifier) ToId() Id {
return Id{Name: n.Name, ScopeContext: n.ScopeContext}
}

func (*Identifier) _expr() {}
func (i *Id) String() string { return i.Name }
func (*Identifier) _expr() {}
2 changes: 1 addition & 1 deletion generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (g *GenVisitor) VisitTryStatement(n *ast.TryStatement) {

if n.Catch != nil {
g.out.WriteString(" catch ")
if n.Catch.Parameter != nil {
if n.Catch.Parameter != nil && n.Catch.Parameter.Target != nil {
g.out.WriteString("(")
g.gen(n.Catch.Parameter)
g.out.WriteString(") ")
Expand Down
6 changes: 3 additions & 3 deletions parser/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ func (p *parser) parseTryStatement() ast.Stmt {
if p.token == token.Catch {
catch := p.idx
p.next()
var parameter ast.Target
var parameter *ast.BindingTarget
if p.token == token.LeftParenthesis {
p.next()
parameter = p.parseBindingTarget()
parameter = &ast.BindingTarget{Target: p.parseBindingTarget()}
p.expect(token.RightParenthesis)
}
node.Catch = &ast.CatchStatement{
Catch: catch,
Parameter: &ast.BindingTarget{Target: parameter},
Parameter: parameter,
Body: p.parseBlockStatement(),
}
}
Expand Down

0 comments on commit f6d634d

Please sign in to comment.