This commit is contained in:
2022-11-03 16:25:29 +01:00
parent 632ed7c089
commit cceefa6375
4 changed files with 23 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
/*
NOTES: For some reason, this code results in the error:
Undeclared variable "inner"
It only occurs under these very specific conditions.
It appears to be a compiler issue, see issue #38 for more info.
*/
fn _getValue(self) {
return self;
}
var cache;
cache = 42.getValue(); //assignment, rather than declaration, allows the bug
print "All good";

View File

@@ -6,7 +6,7 @@
#define TOY_VERSION_MAJOR 0
#define TOY_VERSION_MINOR 6
#define TOY_VERSION_PATCH 0
#define TOY_VERSION_PATCH 1
#define TOY_VERSION_BUILD __DATE__ " " __TIME__
//platform exports/imports

View File

@@ -333,7 +333,7 @@ static Opcode writeCompilerWithJumps(Compiler* compiler, ASTNode* node, void* br
return node->binary.opcode;
}
if (ret != OP_EOF && (node->binary.opcode == OP_AND || node->binary.opcode == OP_OR || (node->binary.opcode >= OP_COMPARE_EQUAL && node->binary.opcode <= OP_INVERT))) {
if (ret != OP_EOF && (node->binary.opcode == OP_VAR_ASSIGN || node->binary.opcode == OP_AND || node->binary.opcode == OP_OR || (node->binary.opcode >= OP_COMPARE_EQUAL && node->binary.opcode <= OP_INVERT))) {
compiler->bytecode[compiler->count++] = (unsigned char)ret; //1 byte
ret = OP_EOF; //untangle in this case
}

View File

@@ -182,6 +182,7 @@ int main() {
"coercions.toy",
"comparisons.toy",
"dot-and-matrix.toy",
"dot-assignments-bugfix.toy",
"dot-chaining.toy",
"functions.toy",
"imports-and-exports.toy",