fixed variables
This commit is contained in:
parent
ce031999e9
commit
60c1e99285
@ -119,15 +119,15 @@ def resolve_call(obj,
|
||||
if len(obj.constraints) == 0:
|
||||
raise CustomError("no methods for unconstrained object")
|
||||
results = [resolve_call(obj, fn, args, assumptions | {obj.name: v}, ctx)
|
||||
for v in obj.assumptions]
|
||||
for v in obj.constraints]
|
||||
for v in results[1:]:
|
||||
if v != results[0]:
|
||||
break
|
||||
else:
|
||||
# same result
|
||||
return results[0]
|
||||
results = [v.inv_subst([a, obj])
|
||||
for v, a in zip(results, obj.assumptions)]
|
||||
results = [v.inv_subst([(a, obj)])
|
||||
for v, a in zip(results, obj.constraints)]
|
||||
for v in results[1:]:
|
||||
if v != results[0]:
|
||||
break
|
||||
|
@ -28,14 +28,15 @@ A = variables['A']
|
||||
i32.methods['__init__'] = ([SelfType(), I], None, set())
|
||||
i32.methods['__add__'] = ([SelfType(), i32], i32, set())
|
||||
i32.methods['__sub__'] = ([SelfType(), i32], i32, set())
|
||||
i32.methods['foo'] = ([SelfType(), i32], i32, set())
|
||||
|
||||
i64.methods['__init__'] = ([SelfType(), I], None, set())
|
||||
i64.methods['__add__'] = ([SelfType(), i64], i64, set())
|
||||
i64.methods['__sub__'] = ([SelfType(), i64], i64, set())
|
||||
i64.methods['foo'] = ([SelfType(), i64], i32, set())
|
||||
|
||||
ctx = Context(variables, types)
|
||||
|
||||
|
||||
def test_call(obj, fn, args, assumptions = {}):
|
||||
args_str = ', '.join([str(v) for v in args])
|
||||
obj_str = '' if obj is None else str(obj) + '.'
|
||||
@ -56,5 +57,7 @@ test_call(i32, '__add__', [])
|
||||
test_call(i32, '__add__', [i32])
|
||||
test_call(i32, '__add__', [i64])
|
||||
test_call(i32, '__add__', [i32, i32])
|
||||
test_call(I, '__add__', [I])
|
||||
test_call(I, 'foo', [I])
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user