Fix assignment type resolution
This commit is contained in:
@@ -24,6 +24,7 @@ main :: (): int
|
||||
|
||||
* **Debuggers**(Visual Studio, Remedybg) **fully work** with the language, you can step through the program
|
||||
* **No external dependencies**, you just setup clang and call build.bat
|
||||
* **No heap allocation** during lifetime of the compiler
|
||||
* Compiles to C code, in the future it will also compile to bytecode and hopefully a raw x64 executable
|
||||
* Very strict Go like type system with untyped literals
|
||||
* **Order independent declarations**
|
||||
|
||||
@@ -7,6 +7,7 @@ Current:
|
||||
- [ ] Typeof operator
|
||||
- [ ] Test and bulletproof any, slices
|
||||
|
||||
- [ ] Need tests that make sure stuff errors out
|
||||
|
||||
Memory:
|
||||
- [ ] Redesign Type map to use List and reduce wasting space
|
||||
|
||||
@@ -1225,8 +1225,9 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str
|
||||
if(!left.is_lvalue) compiler_error(node->pos, "Assigning to rvalue");
|
||||
Operand right = resolve_expr(node->right, AST_CANT_BE_NULL, 0, field_access_scope);
|
||||
|
||||
convert_untyped_to_typed(node->pos, &right.value, left.type);
|
||||
if(left.type != right.type) compiler_error(node->pos, "Can't assign value when left is %Q and right is %Q", typestring(left.type), typestring(right.type));
|
||||
// @warning: Could be buggy, previously we strictly matched if types are exact
|
||||
// need to test this with slices and stuff
|
||||
make_sure_value_is_compatible_with_type(node->pos, &right, left.type, TYPE_AND_EXPR_REQUIRED);
|
||||
|
||||
node->resolved_type = right.type;
|
||||
try_propagating_resolved_type_to_untyped_literals(node->left, node->resolved_type, node->right->resolved_type);
|
||||
|
||||
Reference in New Issue
Block a user