Skip to content

Commit

Permalink
bug fix. about #4
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyschlatter committed Feb 9, 2015
1 parent f717bfd commit 606f703
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,8 @@ func (v *visitor) Visit(node ast.Node) ast.Visitor {

// If this is a defer statement, defer another function right after it that will let the user step into it if they wish.
if def, ok := node.(*ast.DeferStmt); ok {
text := getTextLine(def.Pos())
v.stmtBuf = append(v.stmtBuf, astPrintf(`defer godebug.SLine(ctx, %s, "<Running deferred function>: %s")`, v.scopeVar, text)[0])
text := strconv.Quote("<Running deferred function>: " + getTextLine(def.Pos()))
v.stmtBuf = append(v.stmtBuf, astPrintf(`defer godebug.SLine(ctx, %s, %s)`, v.scopeVar, text)[0])
}

w := &visitor{context: node, scopeVar: v.scopeVar}
Expand Down
3 changes: 3 additions & 0 deletions testdata/regression-in.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ func main() {
c <- true
}()
<-c

// String literal in defer statement.
defer println("Hello")
}
4 changes: 4 additions & 0 deletions testdata/regression-out.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ func main() {
}()
godebug.Line(ctx, scope)
<-c
godebug.Line(ctx, scope)

defer println("Hello")
defer godebug.SLine(ctx, scope, "<Running deferred function>: defer println(\"Hello\")")
}

0 comments on commit 606f703

Please sign in to comment.