Core: More robust '.' access
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
|
||||
|
||||
|
||||
/*@language_refactor: Remove tuples and simplify, Make var unpacking general*/
|
||||
|
||||
/*@language_todo: make polymorphism checking more robust*/
|
||||
@@ -25,24 +22,6 @@ thing := 1
|
||||
|
||||
:goto_block: for
|
||||
|
||||
@reproduction:
|
||||
This kills the compiler due to referencing slice data
|
||||
|
||||
Array :: struct($T: Type)
|
||||
slice: []T
|
||||
cap: S64
|
||||
|
||||
Guy :: struct
|
||||
pos: Vector2
|
||||
|
||||
Add :: (a: *Array($T), item: T)
|
||||
if a.cap == 0
|
||||
a.cap = 16
|
||||
a.slice.data = malloc(sizeof(T) * a.cap)
|
||||
a.slice.data[a.slice.len++] = item
|
||||
|
||||
guys: Array(Guy)
|
||||
Add(&guys, {100, 100})
|
||||
*/
|
||||
|
||||
#import "raylib.core"
|
||||
|
||||
@@ -1344,9 +1344,9 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str
|
||||
if (is_pointer(type)) type = type->base;
|
||||
type_complete(type);
|
||||
|
||||
if (!type->ast) {
|
||||
compiler_error(node->pos, "Builtin type %Q doesn't have anything to access using '.' operator", typestring(type));
|
||||
}
|
||||
bool is_dottable_type = type->kind == TYPE_STRUCT || type->kind == TYPE_UNION;
|
||||
if (is_dottable_type == false) compiler_error(node->pos, "Type %Q doesn't have anything to access using '.' operator", typestring(type));
|
||||
|
||||
scope = ((Ast_Decl *)type->ast)->scope;
|
||||
if (!scope) {
|
||||
compiler_error(node->pos, "Internal compiler error? Type %Q doesn't have scope, you cannot use '.' on this variable", typestring(type));
|
||||
|
||||
Reference in New Issue
Block a user