Skip to content

Commit

Permalink
Ignore voidReturnIsNotAllowed for compiler
Browse files Browse the repository at this point in the history
First alternative of avoidEmpty causes trouble in the compiler:

	&T avoidEmpty(list[&T] _) { return 1; }

Supposed behaviour: when called with empty list, &T is bound to void,
avoidEmpty is therefore forbidden to return 1, hence this alternative
fails and the next one is tried.

Issue in the compiler: the return expression should depend on all type
parameters of the return type. But the constant 1 does not. I do not yet
see how to reconcile this with the return requirement.

Probably, we should completely rewrite this test
  • Loading branch information
PaulKlint committed Mar 17, 2024
1 parent 6ab4d65 commit f9b97fc
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ bool less(&T a, &T b) = a < b;

test bool lessIsConsistentThroughTypeParameters(num x, num y) = (x < y) ==> less(x, y);

&T avoidEmpty(list[&T] _) { return {&T x; 1;} }
@ignoreCompiler{How to make 1 compatible with &T?}
&T avoidEmpty(list[&T] _) { return 1; }
@ignoreCompiler{How to make 1 compatible with &T?}
&T avoidEmpty(list[&T] _) { throw "this should happen"; }

@ignoreCompiler{How to make 1 compatible with &T?}
test bool voidReturnIsNotAllowed() {
try {
avoidEmpty([]);
Expand Down

0 comments on commit f9b97fc

Please sign in to comment.