1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

Merge pull request #849 from Zokrates/fix-complex-type-side-effects

More complete test for pass by value
This commit is contained in:
Thibaut Schaeffer 2021-05-05 23:39:16 +02:00 committed by GitHub
commit 27cd2a9b0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 13 deletions

View file

@ -1,14 +1,14 @@
{ {
"entry_point": "./tests/tests/structs/mutate_argument.zok", "entry_point": "./tests/tests/pass_by_value.zok",
"curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"],
"tests": [ "tests": [
{ {
"input": { "input": {
"values": ["1"] "values": ["1", "1", "1"]
}, },
"output": { "output": {
"Ok": { "Ok": {
"values": ["2", "1"] "values": ["2", "1", "2", "1", "2", "1"]
} }
} }
} }

View file

@ -0,0 +1,18 @@
struct Foo {
field a
}
def mutate(field a) -> field:
a = a + 1
return a
def mutate(Foo f) -> Foo:
f.a = f.a + 1
return f
def mutate(field[1] f) -> field[1]:
f[0] = f[0] + 1
return f
def main(field[1] f, Foo g, field h) -> (field[1], field[1], Foo, Foo, field, field):
return mutate(f), f, mutate(g), g, mutate(h), h

View file

@ -1,10 +0,0 @@
struct Foo {
field a
}
def mutate(field[1] f) -> field[1]:
f[0] = f[0] + 1
return f
def main(field[1] f) -> (field[1], field[1]):
return mutate(f), f