Fix assignment type resolution

This commit is contained in:
Krzosa Karol
2022-10-11 14:20:35 +02:00
parent 061d662f81
commit 7be9a9ef0e
3 changed files with 5 additions and 2 deletions

View File

@@ -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**

View File

@@ -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

View File

@@ -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);