mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
% analysis was incorrect for int vectors.
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
- Better error when casting to a distinct fails.
|
||||
- With single module, name the .o file after what `-o` provides. #1306
|
||||
- Bitstruct members can now have attributes.
|
||||
- `%` analysis was incorrect for int vectors.
|
||||
|
||||
### Stdlib changes
|
||||
|
||||
|
||||
@@ -6010,9 +6010,8 @@ static bool sema_expr_analyse_mod(SemaContext *context, Expr *expr, Expr *left,
|
||||
expr->const_expr.fxx = float_rem(left->const_expr.fxx, right->const_expr.fxx);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (type_is_integer(flat))
|
||||
{
|
||||
assert(type_is_integer(flat));
|
||||
// 3. a % 0 is not valid, so detect it.
|
||||
if (sema_cast_const(right) && int_is_zero(right->const_expr.ixx)) RETURN_SEMA_ERROR(right, "Cannot perform %% with a constant zero.");
|
||||
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import std::io;
|
||||
|
||||
fn void! test_int_mod() @test
|
||||
{
|
||||
int[<2>] y = { 10, 99 };
|
||||
int[<2>] z = { 3, 5 };
|
||||
assert(y % z == { 1, 4 });
|
||||
assert(y / z == { 3, 19 });
|
||||
assert(int[<2>]{ 10, 99 } % int[<2>]{ 3, 5 } == { 1, 4 });
|
||||
assert(int[<2>]{ 10, 99 } / int[<2>]{ 3, 5 } == { 3, 19 });
|
||||
}
|
||||
|
||||
fn void! test_conv() @test
|
||||
{
|
||||
float[<4>] y = { 1, 2, 3, 4 };
|
||||
|
||||
Reference in New Issue
Block a user