enhance(compiler): Better error message for glwe error

This commit is contained in:
Quentin Bourgerie
2021-06-17 10:27:47 +02:00
parent c783d85a84
commit a760ade545
2 changed files with 11 additions and 4 deletions

View File

@@ -100,10 +100,11 @@ unsigned nbBitsFromLog2StdDev(signed log2StdDev, signed bits) {
signed int phantomLeft =
(bits - scalingFactor) - phantomBits - p - paddingBits;
if (phantomLeft < 0) {
// TODO: better message ...
emitError() << "GLWE message cannot be represented "
<< (bits - scalingFactor) << "vs"
<< (phantomBits - p - paddingBits);
emitError() << "GLWE padding + message + phantom = "
<< phantomBits + p + paddingBits
<< " cannot be represented cannot be represented in bits - "
"scalingFactor = "
<< (bits - scalingFactor);
return ::mlir::failure();
}
}

View File

@@ -0,0 +1,6 @@
// RUN: not zamacompiler %s 2>&1| FileCheck %s
// CHECK-LABEL: error: GLWE padding + message + phantom = 25 cannot be represented cannot be represented in bits - scalingFactor = 24
func @glwe(%arg0: !MidLFHE.glwe<{1024,12,64}{15,7,3,40,-25}>) -> !MidLFHE.glwe<{1024,12,64}{15,7,3,40,-25}> {
return %arg0: !MidLFHE.glwe<{1024,12,64}{15,7,3,40,-25}>
}