Resolved #25, Indexing an array with a non-integer causes an error

This commit is contained in:
2023-01-15 15:09:01 +00:00
parent 402abb647c
commit 51740e2b9e
8 changed files with 88 additions and 22 deletions

View File

@@ -26,6 +26,7 @@ typedef enum {
LITERAL_FUNCTION_INTERMEDIATE, //used to process functions in the compiler only
LITERAL_FUNCTION_ARG_REST, //used to process function rest parameters only
LITERAL_FUNCTION_NATIVE, //for handling native functions only
LITERAL_INDEX_BLANK, //for blank indexing i.e. arr[:]
} LiteralType;
typedef struct {
@@ -104,6 +105,10 @@ typedef struct {
#define TO_TYPE_LITERAL(value, c) ((Literal){ LITERAL_TYPE, { .type.typeOf = value, .type.constant = c, .type.subtypes = NULL, .type.capacity = 0, .type.count = 0 }})
#define TO_OPAQUE_LITERAL(value, t) ((Literal){ LITERAL_OPAQUE, { .opaque.ptr = value, .opaque.tag = t }})
//BUGFIX: For blank indexing
#define IS_INDEX_BLANK(value) ((value).type == LITERAL_INDEX_BLANK)
#define TO_INDEX_BLANK_LITERAL ((Literal){LITERAL_INDEX_BLANK, { .integer = 0 }})
TOY_API void freeLiteral(Literal literal);
#define IS_TRUTHY(x) _isTruthy(x)