summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Fusik <piotr@fusion-lang.org>2024-02-28 21:00:21 +0100
committerPiotr Fusik <piotr@fusion-lang.org>2024-02-28 21:00:21 +0100
commit466d5d612143b5f629a69e74ff7e08974398f20d (patch)
tree5de64dcfe85c0747bca0e5f61f4f77225aaaed30
parent66d88e452d6f99f74c88eb381b7488540257f6d6 (diff)
[java] TryParse must assign even on error.
-rw-r--r--GenJava.fu4
-rw-r--r--libfut.cpp4
-rw-r--r--libfut.cs4
-rw-r--r--libfut.js4
4 files changed, 16 insertions, 0 deletions
diff --git a/GenJava.fu b/GenJava.fu
index 2d35c6f..90a69d5 100644
--- a/GenJava.fu
+++ b/GenJava.fu
@@ -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();
}
diff --git a/libfut.cpp b/libfut.cpp
index 41b24d3..47eb93f 100644
--- a/libfut.cpp
+++ b/libfut.cpp
@@ -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();
}
diff --git a/libfut.cs b/libfut.cs
index aceb108..3d113b8 100644
--- a/libfut.cs
+++ b/libfut.cs
@@ -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();
}
diff --git a/libfut.js b/libfut.js
index 8362a87..413a072 100644
--- a/libfut.js
+++ b/libfut.js
@@ -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();
}