diff options
author | Piotr Fusik <piotr@fusion-lang.org> | 2024-02-28 21:00:21 +0100 |
---|---|---|
committer | Piotr Fusik <piotr@fusion-lang.org> | 2024-02-28 21:00:21 +0100 |
commit | 466d5d612143b5f629a69e74ff7e08974398f20d (patch) | |
tree | 5de64dcfe85c0747bca0e5f61f4f77225aaaed30 | |
parent | 66d88e452d6f99f74c88eb381b7488540257f6d6 (diff) |
[java] TryParse must assign even on error.
-rw-r--r-- | GenJava.fu | 4 | ||||
-rw-r--r-- | libfut.cpp | 4 | ||||
-rw-r--r-- | libfut.cs | 4 | ||||
-rw-r--r-- | libfut.js | 4 |
4 files changed, 16 insertions, 0 deletions
@@ -1139,6 +1139,10 @@ public class GenJava : GenTyped CloseBlock(); Write("catch (NumberFormatException e) "); OpenBlock(); + if (!(statement.OnTrue is FuReturn) && !(statement.OnTrue is FuThrow)) { + call.Method.Left.Accept(this, FuPriority.Assign); + WriteLine(" = 0;"); + } statement.OnTrue.AcceptStatement(this); CloseBlock(); } @@ -18482,6 +18482,10 @@ void GenJava::visitIf(const FuIf * statement) closeBlock(); write("catch (NumberFormatException e) "); openBlock(); + if (!dynamic_cast<const FuReturn *>(statement->onTrue.get()) && !dynamic_cast<const FuThrow *>(statement->onTrue.get())) { + call->method->left->accept(this, FuPriority::assign); + writeLine(" = 0;"); + } statement->onTrue->acceptStatement(this); closeBlock(); } @@ -19116,6 +19116,10 @@ namespace Fusion CloseBlock(); Write("catch (NumberFormatException e) "); OpenBlock(); + if (!(statement.OnTrue is FuReturn) && !(statement.OnTrue is FuThrow)) { + call.Method.Left.Accept(this, FuPriority.Assign); + WriteLine(" = 0;"); + } statement.OnTrue.AcceptStatement(this); CloseBlock(); } @@ -19653,6 +19653,10 @@ export class GenJava extends GenTyped this.closeBlock(); this.write("catch (NumberFormatException e) "); this.openBlock(); + if (!(statement.onTrue instanceof FuReturn) && !(statement.onTrue instanceof FuThrow)) { + call.method.left.accept(this, FuPriority.ASSIGN); + this.writeLine(" = 0;"); + } statement.onTrue.acceptStatement(this); this.closeBlock(); } |