mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Another fix to #2226
This commit is contained in:
@@ -1807,6 +1807,7 @@ static OverloadMatch sema_find_typed_operator_in_list(SemaContext *context, Decl
|
||||
if (func->func_decl.operator != operator_overload) continue;
|
||||
if (parent_type && parent_type != typeget(func->func_decl.type_parent)) continue;
|
||||
if ((overload_type & func->func_decl.overload_type) == 0) continue;
|
||||
if (candidate == func) continue;
|
||||
OverloadMatch match = OVERLOAD_MATCH_WILDCARD;
|
||||
if (!func->func_decl.is_wildcard_overload)
|
||||
{
|
||||
|
||||
40
test/test_suite/methods/overload_symmetric_ambiguity.c3t
Normal file
40
test/test_suite/methods/overload_symmetric_ambiguity.c3t
Normal file
@@ -0,0 +1,40 @@
|
||||
module test;
|
||||
typedef Byte = inline ushort;
|
||||
|
||||
macro Byte Byte.add(self, int other) @operator_s(+) => (Byte)((ushort)self + (ushort)other);
|
||||
|
||||
|
||||
fn int main(String[] args)
|
||||
{
|
||||
Byte b = 2;
|
||||
Byte c = 1;
|
||||
Byte d = c + b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
|
||||
define i32 @test.main([2 x i64] %0) #0 {
|
||||
entry:
|
||||
%args = alloca %"char[][]", align 8
|
||||
%b = alloca i16, align 2
|
||||
%c = alloca i16, align 2
|
||||
%d = alloca i16, align 2
|
||||
%self = alloca i16, align 2
|
||||
store [2 x i64] %0, ptr %args, align 8
|
||||
store i16 2, ptr %b, align 2
|
||||
store i16 1, ptr %c, align 2
|
||||
%1 = load i16, ptr %c, align 2
|
||||
store i16 %1, ptr %self, align 2
|
||||
%2 = load i16, ptr %b, align 2
|
||||
%zext = zext i16 %2 to i32
|
||||
%3 = load i16, ptr %self, align 2
|
||||
%zext1 = zext i16 %3 to i32
|
||||
%trunc = trunc i32 %zext to i16
|
||||
%zext2 = zext i16 %trunc to i32
|
||||
%add = add i32 %zext1, %zext2
|
||||
%trunc3 = trunc i32 %add to i16
|
||||
store i16 %trunc3, ptr %d, align 2
|
||||
ret i32 0
|
||||
}
|
||||
Reference in New Issue
Block a user