BUGFIX: Integer and float comparisons always return true

This commit is contained in:
2023-02-26 01:27:21 +11:00
parent e9b347acb6
commit 1064b69d04
2 changed files with 4 additions and 4 deletions

View File

@@ -5,8 +5,8 @@
#include <stdint.h> #include <stdint.h>
#define TOY_VERSION_MAJOR 1 #define TOY_VERSION_MAJOR 1
#define TOY_VERSION_MINOR 0 #define TOY_VERSION_MINOR 1
#define TOY_VERSION_PATCH 1 #define TOY_VERSION_PATCH 0
#define TOY_VERSION_BUILD __DATE__ " " __TIME__ #define TOY_VERSION_BUILD __DATE__ " " __TIME__
//platform/compiler-specific instructions //platform/compiler-specific instructions

View File

@@ -241,10 +241,10 @@ bool Toy_literalsAreEqual(Toy_Literal lhs, Toy_Literal rhs) {
// ints and floats are compatible // ints and floats are compatible
if ((TOY_IS_INTEGER(lhs) || TOY_IS_FLOAT(lhs)) && (TOY_IS_INTEGER(rhs) || TOY_IS_FLOAT(rhs))) { if ((TOY_IS_INTEGER(lhs) || TOY_IS_FLOAT(lhs)) && (TOY_IS_INTEGER(rhs) || TOY_IS_FLOAT(rhs))) {
if (TOY_IS_INTEGER(lhs)) { if (TOY_IS_INTEGER(lhs)) {
return TOY_AS_INTEGER(lhs) + TOY_AS_FLOAT(rhs); return TOY_AS_INTEGER(lhs) == TOY_AS_FLOAT(rhs);
} }
else { else {
return TOY_AS_FLOAT(lhs) + TOY_AS_INTEGER(rhs); return TOY_AS_FLOAT(lhs) == TOY_AS_INTEGER(rhs);
} }
} }