From f2959795330966f13cb65bbb6034c88a01fc0bcc Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Fri, 9 Jun 2017 10:14:11 +0200 Subject: [PATCH] Emit a maximum of one error var when generating verifiers, fixes #786 --- src/verifier.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/verifier.js b/src/verifier.js index 4d302ba02..b5ddc29ad 100644 --- a/src/verifier.js +++ b/src/verifier.js @@ -29,10 +29,13 @@ function genVerifyValue(gen, field, fieldIndex, ref) { gen ("break") ("}"); - } else gen - ("var e=types[%i].verify(%s);", fieldIndex, ref) + } else { + gen + ((gen.hasErrorVar ? "" : "var ") + "e=types[%i].verify(%s);", fieldIndex, ref) ("if(e)") ("return%j+e", field.name + "."); + gen.hasErrorVar = true; + } } else { switch (field.type) { case "int32":