fuzion
fuzion copied to clipboard
Pre- and Postcondition failures when compiling small example using effect and type parameter
Using this example
s.q
s(p X) : effect is
s =>
s.default
s.env
I get this crash
> PRECONDITIONS=true POSTCONDITIONS=true ~/fuzion/clean/fuzion/./build/bin/fz -verbose=3 sockets_test_crash.fz
/home/fridi/fuzion/fuzion/sockets_test_crash.fz:4:3: error 1: Failed to infer type of expression.
s.default
Expression with unknown type: 's'
error 2: java.lang.Error: ensure-condition failed: ResolvedNormalType.java:289 "(feature().generics().sizeMatches(generics()));"
at dev.flang.util.ANY.ensure(ANY.java:293)
at dev.flang.ast.ResolvedNormalType.<init>(ResolvedNormalType.java:289)
at dev.flang.ast.ResolvedNormalType.create(ResolvedNormalType.java:298)
at dev.flang.ast.ResolvedNormalType.asRef(ResolvedNormalType.java:426)
while a slightly smaller example
s.q
s(p X) : effect is
s =>
s.env
results in a different crash
> PRECONDITIONS=true POSTCONDITIONS=true ~/fuzion/clean/fuzion/./build/bin/fz -verbose=3 sockets_test_crash2.fz
error 1: java.lang.Error: require-condition5 failed: AbstractType.java:785 "(checkedForGeneric(), target != null, target.checkedForGeneric(), Errors.any() || !isOpenGeneric(), Errors.any() || target.isGenericArgument() || target.feature().generics().sizeMatches(target.generics()));"
at dev.flang.util.ANY.require(ANY.java:183)
at dev.flang.ast.AbstractType.applyTypePars(AbstractType.java:785)
at dev.flang.ast.Call.getActualResultType(Call.java:1402)
at dev.flang.ast.Call.setActualResultType(Call.java:2496)
at dev.flang.ast.Call.resolveTypes(Call.java:2453)
at dev.flang.ast.Feature$ResolveTypes.action(Feature.java:1451)
at dev.flang.ast.Feature$ResolveTypes.action(Feature.java:1441)
at dev.flang.ast.Call.visit(Call.java:1112)
This is due to free types not working properly. This works:
s.q
s(X type, p X) : effect is
s =>
s.env