diff --git a/new_ast.cpp b/new_ast.cpp index 34314eb..5ba7281 100644 --- a/new_ast.cpp +++ b/new_ast.cpp @@ -325,7 +325,8 @@ ast_float(Token *pos, F64 value){ } function Ast_Atom * -ast_int(Token *pos, S64 integer){ +ast_int(Token *pos, U64 integer){ + assert(integer <= S64MAX); AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM); result->type = untyped_int; result->int_val = integer; diff --git a/new_types.kl b/new_types.kl index 7cde920..08dda11 100644 --- a/new_types.kl +++ b/new_types.kl @@ -1,13 +1,13 @@ unary_test :: () - int_val :: 1251525 - uns: U64 = -int_val + int_val :: 125152553512512512512 // @todo float_val :: 124.42 conversion: F64 = -+int_val float2 := -float_val unsigned: Int = -+-+-int_val + // uns: U64 = -int_val // int_float: S64 = float_val // string :: -"Thing" // boolean :: -true diff --git a/typecheck.cpp b/typecheck.cpp index 6f17265..6fd70d7 100644 --- a/typecheck.cpp +++ b/typecheck.cpp @@ -15,6 +15,7 @@ convert_untyped(Token *pos, Value a, Ast_Resolved_Type *new_type){ assert(is_untyped(a.type)); assert(new_type); + assert(a.int_val <= S64MAX); if(is_int(a.type) && is_int(new_type)){ assert(a.type == untyped_int); switch(new_type->kind){ @@ -57,6 +58,7 @@ convert_untyped(Token *pos, Value a, Ast_Resolved_Type *new_type){ function S64 value_get_int(Value value){ + assert(value.int_val <= S64MAX); assert(is_float(value.type) || is_int(value.type)); S64 result = 0; switch(value.type->kind){ @@ -579,7 +581,6 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *lambda_to_res Value value = eval_unary(node->pos, node->op, op.value); rewrite_into_const(node, Ast_Unary, value); return operand_const_rvalue(value); - } return operand_rvalue(op.type); }break;