diff --git a/resources/testfragments/super_simple.c3 b/resources/testfragments/super_simple.c3 index b77f2fe85..641e6d345 100644 --- a/resources/testfragments/super_simple.c3 +++ b/resources/testfragments/super_simple.c3 @@ -35,14 +35,13 @@ enum EnumWithData : ushort (int a, char[] x, long b = 4) TEST2(12, "world") } -/* enum EnumTestNoOverflowAfterULong : ulong { VALUE = 0xFFFF_FFFF_FFFF_FFFE, VALUE_NO_EXCEED } - +$if (false) { enum EnumTestOverflowAfterLong : long { @@ -60,7 +59,9 @@ enum EnumTestOverflowAfter { VALUE = 0x80000000 - 1, VALUE_EXCEED -}*/ +} + +} @@ -158,7 +159,7 @@ func TestStruct2 structTest(int i) func void enumInferenceTest() { -// OtherError e = OtherError.FOO_BAR; + OtherError e = OtherError.FOO_BAR; Inf x = Inf.A; x = BooInf.B; x = A; @@ -190,11 +191,11 @@ func int jumptest() LABELX: return 2; } -/* func int borok() throws { return 1; -}*/ +} + func void testNoReturn() { int i = 0; @@ -536,7 +537,7 @@ func void test_expr_block(int x) if (x == 0) return 100; return -x; }); - //printf("The result was %d\n", a); + printf("The result was %d\n", a); } func int expr_block() diff --git a/src/compiler/sema_stmts.c b/src/compiler/sema_stmts.c index 0e438ccfc..68266c3ac 100644 --- a/src/compiler/sema_stmts.c +++ b/src/compiler/sema_stmts.c @@ -1130,12 +1130,11 @@ bool sema_analyse_function_body(Context *context, Decl *func) current = current->defer_stmt.prev_defer; } } - bool error_was_useful = vec_size(context->throw) > 0; + bool error_was_useful = signature->error_return == ERROR_RETURN_NONE; VECEACH(context->error_calls, i) { Throw *throw = &context->error_calls[i]; if (throw->throw_info->is_completely_handled) continue; - switch (signature->error_return) { case ERROR_RETURN_NONE: @@ -1151,20 +1150,18 @@ bool sema_analyse_function_body(Context *context, Decl *func) case ERROR_RETURN_MANY: case ERROR_RETURN_ONE: // Try to add a catch. - if (throw_add_error_return_catch(throw, signature->throws)) - { - error_was_useful = true; - } + error_was_useful = true; + throw_add_error_return_catch(throw, signature->throws); break; } - // If it's fully catched, then fine. + // If it's fully caught, then fine. if (throw->throw_info->is_completely_handled) continue; // Otherwise error. SEMA_ERROR(throw, "The errors returned by the call must be completely caught in a catch or else the function current must be declared to throw."); return false; } - if (!error_was_useful) + if (!error_was_useful && !vec_size(context->throw)) { // Warning here? }