diff --git a/compiler/compile.go b/compiler/compile.go index 94a3b61..a18c7a3 100644 --- a/compiler/compile.go +++ b/compiler/compile.go @@ -329,7 +329,7 @@ func createConstant() Constant { newConst.value.variant = valueT.value case TOKEN_CONSTANT_FALSE: newConst.value.kind = BOOLEAN - newConst.value.variant = false + newConst.value.variant = 0 case TOKEN_CONSTANT_INT: newConst.value.kind = INT64 newConst.value.variant = valueT.value @@ -338,7 +338,7 @@ func createConstant() Constant { newConst.value.variant = valueT.value case TOKEN_CONSTANT_TRUE: newConst.value.kind = BOOLEAN - newConst.value.variant = true + newConst.value.variant = 1 default: if isParsingFunction() { parser.currentFn.error = true diff --git a/tests/constants.sk b/tests/constants.sk index fa07bf9..52d1147 100644 --- a/tests/constants.sk +++ b/tests/constants.sk @@ -5,10 +5,20 @@ using io ; making sure consts are evaluated correctly const thirty 30 +const name "Stanczyk" +const isTrue true +const isFalse false +const oneByte '0' fn main () const twenty 20 + const type "compiler" "30 " print thirty println "20 " print twenty println + "Stanczyk " print name println + "compiler " print type println + "true " print isTrue println + "false " print isFalse println + "48 " print oneByte println ret diff --git a/tests/constants.txt b/tests/constants.txt index 4441adc..4dc5b93 100644 --- a/tests/constants.txt +++ b/tests/constants.txt @@ -1,2 +1,7 @@ 30 30 20 20 +Stanczyk Stanczyk +compiler compiler +true true +false false +48 48