Skip to content

Commit

Permalink
Panic if asked to generate multi-argument invokes
Browse files Browse the repository at this point in the history
Presently, Java code generation does not support the `MultiArgumentInputs` field
on invokes. When set, this flag instructs the generation of functions that take
multiple independent arguments instead of a single object containing all
arguments. For example, instead of:

```java
Class.function(FunctionArgs.build().setA(a).setB(b).build());
```

we might generate:

```java
Class.function(a, b);
```

Since it is not supported, the correct behaviour is to panic and abort code
generation, as we do in other languages with this limitation (e.g. Python).
Currently, however, Java does not, proceeding instead to generate incorrect
code. This change fixes that, panicking if `MultiArgumentInputs` is true. This
is technically breaking, but a bug fix (and in theory, any SDKs we have
generated would already be panicking for Python, so the feeling is that this
likely not a highly used feature).

Fixes #1598
  • Loading branch information
lunaris committed Jan 17, 2025
1 parent c74ed23 commit 4ae6256
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/codegen/java/gen_program_expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
// Assuming the existence of the following helper method
g.Fgenf(w, "computeFileBase64Sha256(%v)", expr.Args[0])
case pcl.Invoke:
if expr.Signature.MultiArgumentInputs {
err := fmt.Errorf("Java program-gen does not implement MultiArgumentInputs for function '%v'",
expr.Args[0])
panic(err)
}

fullyQualifiedType, funcName := g.functionImportDef(expr.Args[0])
if !g.emittedTypeImportSymbols.Has(fullyQualifiedType) {
// the fully qualified name isn't emitted
Expand Down

0 comments on commit 4ae6256

Please sign in to comment.