id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,planetversion,pltversion
8,bad parenthesization in pretty-printing,dherman,dherman,"Dave Gurnell wrote:

> The following code:

{{{
   #lang scheme/base

   (require (planet ""syntax/sexp.ss"" (""dherman"" ""javascript.plt"" 5))
            (planet ""syntax/pretty-print.ss"" (""dherman"" ""javascript.plt"" 5)))

   (pretty-print (sexp->SourceElement '((function (a b) (return (+ a b))) 1 2)))
}}}

> prints out:

{{{
   function(a, b) {
       return a + b;
   }(1, 2);
}}}

> when I think the correct JS should contain a parenthesised function block:

{{{
   (function(a, b) {
       return a + b;
   })(1, 2);
}}}

> I got this working by making the method-call clause of sexp->Expression wrap a ParenExpression around the method when the method is a FunctionExpression:

{{{
      ; ...
      [(method args ...)
       (let ([method-expr (sexp->Expression method)])
         (if (FunctionExpression? method-expr)
             (make-CallExpression #f (make-ParenExpression #f method-expr) (map sexp->Expression args))
             (make-CallExpression #f method-expr (map sexp->Expression args))))]
      ; ...
}}}

> Does that seem right to you?
",defect,closed,major,,dherman/javascript.plt,,,,,4.0
