Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Sep 25, 2017
1 parent a246ed9 commit 2eaefe3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 3.0

>This is a major release with breaking changes. This release is no longer strictly backward compatible with `lightscript@0.5.9`. Where compatibility has been broken, we believe we are correctly anticipating the future development of JavaScript and LightScript.
## Missing branches of conditional constructs produce `undefined`

### Change:
Expand Down Expand Up @@ -60,3 +62,29 @@ a == null ? void 0 : (_a = a[b++]) == null ? void 0 : _a.c;
```
This is a **breaking change** to language semantics! Most user code should not be affected, as it should not rely on this kind of side effect ordering -- but please do note the possible impact here.
### Rationale:
Here we are converging with the direction that JavaScript proper is headed in, as well as picking up some bug fixes along the way.
## Miscellaneous
#### Conditional comprehension syntax change
Conditional comprehensions were added in 2.0 (with the `{enhancedComprehension: true}` flag) using the `case` keyword:
```js
x = [
"first"
case shouldAddSecond: "second"
]
```
The syntax has been changed to `only if`:
```js
x = [
"first"
only if shouldAddSecond: "second"
]
```
The `only if` syntax makes it much clearer what this conditional comprehension code is doing.
2 changes: 2 additions & 0 deletions src/util/statementsToExpression.lsc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gatherSequenceExpressions(nodes: Array<Object>): ?Object ->
exprs = []
let ensureLastNull = true

// TODO: comprehension
for elem node in nodes:
now ensureLastNull = false

Expand Down Expand Up @@ -43,6 +44,7 @@ gatherSequenceExpressions(nodes: Array<Object>): ?Object ->
if ensureLastNull:
exprs.push(t.nullLiteral()~atNode(exprs[exprs.length - 1]))

// TODO: sourcemap
if exprs.length == 1: exprs[0] else: t.sequenceExpression(exprs)

toSequenceExpression(nodes: Array<Object>): ?Object ->
Expand Down

0 comments on commit 2eaefe3

Please sign in to comment.