diff --git a/src/build/core/ExpressionToMemory.go b/src/build/core/ExpressionToMemory.go index d876c7b..781b378 100644 --- a/src/build/core/ExpressionToMemory.go +++ b/src/build/core/ExpressionToMemory.go @@ -5,12 +5,11 @@ import ( "git.akyoto.dev/cli/q/src/build/errors" "git.akyoto.dev/cli/q/src/build/expression" "git.akyoto.dev/cli/q/src/build/sizeof" - "git.akyoto.dev/cli/q/src/build/token" ) // ExpressionToMemory puts the result of an expression into the specified memory address. func (f *Function) ExpressionToMemory(node *expression.Expression, memory asm.Memory) error { - if node.IsLeaf() && (node.Token.Kind == token.Number || node.Token.Kind == token.Rune) { + if node.IsLeaf() && node.Token.IsNumeric() { number, err := f.Number(node.Token) if err != nil { diff --git a/tests/programs/reassign.q b/tests/programs/reassign.q index 26aa3e8..4c6fa45 100644 --- a/tests/programs/reassign.q +++ b/tests/programs/reassign.q @@ -1,6 +1,6 @@ main() { - x := 1 - y := x + 1 - x = 2 - assert y == 2 + a := 1 + b := a + 1 + a = 2 + assert b == 2 } \ No newline at end of file diff --git a/tests/programs/variables.q b/tests/programs/variables.q new file mode 100644 index 0000000..aa461ab --- /dev/null +++ b/tests/programs/variables.q @@ -0,0 +1,15 @@ +main() { + a := 1 + b := 2 + c := 3 + d := 4 + e := 5 + f := 6 + g := 7 + h := 8 + + assert a != b + assert c != d + assert e != f + assert g != h +} \ No newline at end of file diff --git a/tests/programs_test.go b/tests/programs_test.go index 5dfce4e..6fbc5fe 100644 --- a/tests/programs_test.go +++ b/tests/programs_test.go @@ -20,8 +20,9 @@ var programs = []struct { }{ {"empty", "", "", 0}, {"assert", "", "", 1}, - {"reuse", "", "", 0}, + {"variables", "", "", 0}, {"reassign", "", "", 0}, + {"reuse", "", "", 0}, {"return", "", "", 0}, {"binary", "", "", 0}, {"octal", "", "", 0},