Skip to content

Commit f23426a

Browse files
committed
Fix Identifier dumping
1 parent eeaa6ed commit f23426a

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

ast/dump.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func Dump(ast Ast) string {
4444
switch x := v.(type) {
4545
case py.String:
4646
args = append(args, fmt.Sprintf("%s=%q", fname, string(x)))
47+
case Identifier:
48+
args = append(args, fmt.Sprintf("%s='%s'", fname, string(x)))
4749
case ModBase:
4850
case StmtBase:
4951
case ExprBase:

ast/dump_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestDump(t *testing.T) {
2121
{&Module{Body: []Stmt{&Pass{}}}, `Module(body=[Pass()])`},
2222
{&Module{Body: []Stmt{&ExprStmt{Value: &Tuple{}}}}, `Module(body=[Expr(value=Tuple(elts=[], ctx=UnknownExprContext(0)))])`},
2323
{&NameConstant{Value: py.True}, `NameConstant(value=True)`},
24+
{&Name{Id: Identifier("hello"), Ctx: Load}, `Name(id='hello', ctx=Load())`},
2425
} {
2526
out := Dump(test.in)
2627
if out != test.out {

0 commit comments

Comments
 (0)