mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
The any type is now recognized as a type properly
This commit is contained in:
@@ -628,6 +628,14 @@ static Toy_Opcode castingPrefix(Toy_Parser* parser, Toy_ASTNode** nodeHandle) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//BUGFIX: handle this here, and not in castingPrefix, so "any" can be recognized as a type properly
|
||||||
|
case TOY_TOKEN_ANY: {
|
||||||
|
Toy_Literal literal = TOY_TO_TYPE_LITERAL(TOY_LITERAL_ANY, false);
|
||||||
|
Toy_emitASTNodeLiteral(nodeHandle, literal);
|
||||||
|
Toy_freeLiteral(literal);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
error(parser, parser->previous, "Unexpected token passed to casting precedence rule");
|
error(parser, parser->previous, "Unexpected token passed to casting precedence rule");
|
||||||
return TOY_OP_EOF;
|
return TOY_OP_EOF;
|
||||||
@@ -940,7 +948,7 @@ ParseRule parseRules[] = { //must match the token types
|
|||||||
{NULL, NULL, PREC_NONE},// TOKEN_DICTIONARY,
|
{NULL, NULL, PREC_NONE},// TOKEN_DICTIONARY,
|
||||||
{NULL, NULL, PREC_NONE},// TOKEN_FUNCTION,
|
{NULL, NULL, PREC_NONE},// TOKEN_FUNCTION,
|
||||||
{NULL, NULL, PREC_NONE},// TOKEN_OPAQUE,
|
{NULL, NULL, PREC_NONE},// TOKEN_OPAQUE,
|
||||||
{NULL, NULL, PREC_NONE},// TOKEN_ANY,
|
{castingPrefix, NULL, PREC_CALL},// TOKEN_ANY,
|
||||||
|
|
||||||
//keywords and reserved words
|
//keywords and reserved words
|
||||||
{NULL, NULL, PREC_NONE},// TOKEN_AS,
|
{NULL, NULL, PREC_NONE},// TOKEN_AS,
|
||||||
|
|||||||
@@ -22,4 +22,9 @@ var dict: complex = [
|
|||||||
"third array": [7, 8, 9]
|
"third array": [7, 8, 9]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
//check the any type is recognized as a type within an array
|
||||||
|
var a: [type] = [int, bool, any];
|
||||||
|
|
||||||
|
|
||||||
print "All good";
|
print "All good";
|
||||||
|
|||||||
Reference in New Issue
Block a user