Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

defvar within function generates two semicolons #48

Closed
mfrawley opened this Issue May 21, 2012 · 4 comments

Comments

Projects
None yet
4 participants

From your REPL demo:

(defun alert-hello (planet-name)
(defvar message (concat "hello " planet-name))
(alert message)
message)

generates:
var alertHello = (function(planetName) {
// planetName:required
var message = ("hello " + planetName);;
alert(message);
return message;
});

btw I love the project, was working on something v. similar (forked from lava-script by Evan Murphy) till I found this. If I can help out I will.

matthewp added a commit to matthewp/sibilant that referenced this issue Oct 17, 2012

Fixes issue #48, double semi-colons when defvar used within defun
The problem is that defun calls macros.lamba which automatically inserts the semicolon on the end of lines. Since defvar also inserts the semicolon you wind up with 2 semicolons. This isn't a problem in JavaScript, just a prettiness problem.

The fix is to check to see if the last character in the statement is a semicolon, and if it is to not do the insertion.

matthewp added a commit to matthewp/sibilant that referenced this issue Oct 17, 2012

Contributor

matthewp commented Oct 17, 2012

That pull request fixes the issue.

jbr added a commit that referenced this issue Oct 17, 2012

Merge pull request #49 from matthewp/defvar
Fixes issue #48, double semi-colons when defvar used within defun

http://sibilantjs.info still produces this error.

(defun test ()
 (defvar x [])
 x)

produces:

var test = (function() {
  var x = [  ];;
  return x;
});
Owner

jbr commented Jan 11, 2013

website updated

@jbr jbr closed this Jan 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment