Skip to content

Commit f02ef27

Browse files
committed
set nya as 0
1 parent d81a198 commit f02ef27

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414

1515
# Dependency directories (remove the comment below to include it)
1616
# vendor/
17+
main.wasm

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ sada
5555

5656
* `da` True in boolean
5757
* `nye` False in boolean
58-
* `nya` null, nil
58+
* `nya` null, nil, 0
5959
* `unu` one, 1
6060
* `du` two, 2
6161
* `unudu` three, 3

Diff for: elementary.go

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func truthExpr(t bool) *Expr {
9494
}
9595

9696
func (c *Context) getNumber(expr *Expr) int {
97+
if expr.isNya() {
98+
return 0
99+
}
97100
if !expr.isNumber() {
98101
errorf("expect number; got %v", expr)
99102
}

Diff for: eval.go

+4
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ func (e *Expr) isTrue() bool {
344344
return e != nil && e.sada == tokDa
345345
}
346346

347+
func (e *Expr) isNya() bool {
348+
return e == nil || e.sada == tokNya
349+
}
350+
347351
func (e *Expr) length() int {
348352
if e == nil {
349353
return 0

0 commit comments

Comments
 (0)