Skip to content
Permalink
Browse files

Merge branch '1.4.x'

  • Loading branch information...
odino committed Jun 7, 2019
2 parents 9322877 + b9d7957 commit cedcfc12b997f9276a9e40a4f4e759140236b0fc
Showing with 11 additions and 31 deletions.
  1. +1 −1 docs/installer.sh
  2. +1 −1 docs/types/builtin-function.md
  3. +6 −28 evaluator/evaluator.go
  4. +2 −0 evaluator/evaluator_test.go
  5. +1 −1 main.go
@@ -27,7 +27,7 @@ if [ "${MACHINE_TYPE}" = 'x86_64' ]; then
ARCH="amd64"
fi

VERSION=1.4.0
VERSION=1.4.1

echo "Trying to detect the details of your architecture."
echo ""
@@ -243,7 +243,7 @@ $ cat ~/.absrc
source("~/abs/lib/library.abs")
$ abs
Hello user, welcome to the ABS (1.4.0) programming language!
Hello user, welcome to the ABS (1.4.1) programming language!
Type 'quit' when you are done, 'help' if you get lost!
⧐ adder(1, 2)
3
@@ -423,7 +423,7 @@ func evalInfixExpression(
case left.Type() == object.HASH_OBJ && right.Type() == object.HASH_OBJ:
return evalHashInfixExpression(tok, operator, left, right)
case operator == "in":
return evalInExpression(left, right)
return evalInExpression(tok, left, right)
case operator == "==":
return nativeBoolToBooleanObject(left == right)
case operator == "!=":
@@ -436,31 +436,11 @@ func evalInfixExpression(
}

func evalBangOperatorExpression(right object.Object) object.Object {
switch right {
case TRUE:
if isTruthy(right) {
return FALSE
case FALSE:
return TRUE
case NULL:
return TRUE
default:
switch o := right.(type) {
case *object.String:
if o.Value == o.ZeroValue() {
return TRUE
}

return FALSE
case *object.Number:
if o.Value == o.ZeroValue() {
return TRUE
}

return FALSE
default:
return FALSE
}
}

return TRUE
}

func evalTildePrefixOperatorExpression(tok token.Token, right object.Object) object.Object {
@@ -575,7 +555,7 @@ func evalStringInfixExpression(
}

if operator == "in" {
return evalInExpression(left, right)
return evalInExpression(tok, left, right)
}

return newError(tok, "unknown operator: %s %s %s", left.Type(), operator, right.Type())
@@ -616,9 +596,7 @@ func evalHashInfixExpression(
return newError(tok, "unknown operator: %s %s %s", left.Type(), operator, right.Type())
}

func evalInExpression(
left, right object.Object,
) object.Object {
func evalInExpression(tok token.Token, left, right object.Object) object.Object {
var found bool

switch rightObj := right.(type) {
@@ -1061,6 +1061,8 @@ func TestInExpressions(t *testing.T) {
expected interface{}
}{
{`1 in [1]`, true},
{`1 in []`, false},
{`!(1 in [])`, true},
{`1 in ["1"]`, false},
{`"1" in [1]`, false},
{`1 in [1, 2]`, true},
@@ -7,7 +7,7 @@ import (
"github.com/abs-lang/abs/repl"
)

var Version = "1.4.0"
var Version = "1.4.1"

// The ABS interpreter
func main() {

0 comments on commit cedcfc1

Please sign in to comment.
You can’t perform that action at this time.