Skip to content

Commit

Permalink
Invalid comparison throws Incomparable_Values rather than Type_Error
Browse files Browse the repository at this point in the history
  • Loading branch information
Akirathan committed Apr 15, 2023
1 parent 8718c99 commit eca0069
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ boolean doBigInteger(EnsoBigInteger self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(EnsoBigInteger self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ boolean doBigInteger(EnsoBigInteger self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(EnsoBigInteger self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ boolean doBigInteger(EnsoBigInteger self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(EnsoBigInteger self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ boolean doBigInteger(EnsoBigInteger self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(EnsoBigInteger self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ boolean doBigInteger(double self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(double self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ boolean doBigInteger(double self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(double self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ boolean doBigInteger(double self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(double self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ boolean doBigInteger(double self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(double self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.error.DataflowError;
import org.enso.interpreter.runtime.number.EnsoBigInteger;
import org.enso.interpreter.runtime.util.Utils;

@BuiltinMethod(type = "Small_Integer", name = ">", description = "Comparison of numbers.")
public abstract class GreaterNode extends Node {
Expand Down Expand Up @@ -35,7 +36,7 @@ boolean doBigInteger(long self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(long self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ boolean doBigInteger(long self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(long self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.error.DataflowError;
import org.enso.interpreter.runtime.number.EnsoBigInteger;
import org.enso.interpreter.runtime.util.Utils;

@BuiltinMethod(type = "Small_Integer", name = "<", description = "Comparison of numbers.")
public abstract class LessNode extends Node {
Expand Down Expand Up @@ -35,7 +36,7 @@ boolean doBigInteger(long self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(long self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.error.DataflowError;
import org.enso.interpreter.runtime.number.EnsoBigInteger;
import org.enso.interpreter.runtime.util.Utils;

@BuiltinMethod(type = "Small_Integer", name = "<=", description = "Comparison of numbers.")
public abstract class LessOrEqualNode extends Node {
Expand Down Expand Up @@ -35,7 +36,7 @@ boolean doBigInteger(long self, EnsoBigInteger that) {
@Fallback
DataflowError doOther(long self, Object that) {
var builtins = EnsoContext.get(this).getBuiltins();
var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that");
return DataflowError.withoutTrace(typeError, this);
var incomparableValsErr = builtins.error().makeIncomparableValues(self, that);
return DataflowError.withoutTrace(incomparableValsErr, this);
}
}

0 comments on commit eca0069

Please sign in to comment.