Skip to content

Commit

Permalink
throw exception when more unquote then quasiquotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed May 21, 2019
1 parent cd0cb90 commit ea64715
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* text eol=lf
.* text eol=lf
dist/* binary
package-lock.json binary
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* fix `ignore` macro
* fix `load` function in node
* fix `Pair::append` and `append` functions with non pair
* throw exception when more unquote then quasiquotes

## 0.15.1
### Bug fixes
Expand Down
6 changes: 5 additions & 1 deletion dist/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* http://javascript.nwbox.com/ContentLoaded/
* http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
*
* build: Sun, 19 May 2019 14:23:49 +0000
* build: Tue, 21 May 2019 17:19:22 +0000
*/
(function () {
'use strict';
Expand Down Expand Up @@ -4239,6 +4239,10 @@ function _typeof(obj) {
parent = node;
unquote_cnt++;
node = node.car.cdr.car;
}

if (unquote_cnt > max_unq) {
throw new Error("You can't call `unquote` outside of quasiquote");
} // we use Unquote to proccess inner most unquote first
// in unquote function afer processing whole s-expression

Expand Down
4 changes: 2 additions & 2 deletions dist/lips.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/helpers.lips
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
(setTimeout (lambda ()
(resolve (begin ,@expr)))
,time))))

;; ---------------------------------------------------------------------------------------
(define (pair-map fn seq-list)
"(seq-map fn list)
Expand Down
3 changes: 3 additions & 0 deletions src/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -2787,6 +2787,9 @@
unquote_cnt++;
node = node.car.cdr.car;
}
if (unquote_cnt > max_unq) {
throw new Error(`You can't call \`unquote\` outside of quasiquote`);
}
// we use Unquote to proccess inner most unquote first
// in unquote function afer processing whole s-expression
if (parent === node) {
Expand Down

0 comments on commit ea64715

Please sign in to comment.