Browse Source

Fix lhs < rhs bug (#164)

gingerBill 7 years ago
parent
commit
1b6a14ac39
2 changed files with 3 additions and 4 deletions
  1. 1 1
      src/build_settings.cpp
  2. 2 3
      src/check_expr.cpp

+ 1 - 1
src/build_settings.cpp

@@ -263,7 +263,7 @@ String path_to_fullpath(gbAllocator a, String s) {
 	gb_mutex_lock(&string_buffer_mutex);
 	p = realpath(cast(char *)s.text, 0);
 	gb_mutex_unlock(&string_buffer_mutex);
-	if(p == nullptr) return make_string_c("");
+	if(p == nullptr) return String{};
 	return make_string_c(p);
 }
 #else

+ 2 - 3
src/check_expr.cpp

@@ -3884,7 +3884,7 @@ break;
 
 isize add_dependencies_from_unpacking(Checker *c, Entity **lhs, isize lhs_count, isize tuple_index, isize tuple_count) {
 	if (lhs != nullptr) {
-		for (isize j = 0; tuple_index < lhs_count && j < tuple_count; j++) {
+		for (isize j = 0; (tuple_index + j) < lhs_count && j < tuple_count; j++) {
 			Entity *e = lhs[tuple_index + j];
 			DeclInfo *decl = decl_info_of_entity(&c->info, e);
 			if (decl != nullptr) {
@@ -5421,14 +5421,13 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
 
 			i64 max = 0;
 			isize index = 0;
-			isize elem_count = cl->elems.count;
 
 			Type *bet = base_type(elem_type);
 			if (!elem_type_can_be_constant(bet)) {
 				is_constant = false;
 			}
 
-			for (; index < elem_count; index++) {
+			for (; index < cl->elems.count; index++) {
 				AstNode *e = cl->elems[index];
 				if (e == nullptr) {
 					error(node, "Invalid literal element");