bug with arguments

This commit is contained in:
DieMyst 2022-02-09 12:53:30 +03:00
parent 3d3280d2e7
commit 18771e655d
4 changed files with 101 additions and 3 deletions

View File

@ -11,3 +11,6 @@ func passFunctionAsArg(node: string, str: string, c: string -> string):
-- then return on a node
Peer.identify()
print(res)
func reproArgsBug426(log: string -> (), arg: string):
log(arg)

View File

@ -1,6 +1,6 @@
import {Fluence, FluencePeer, setLogLevel} from '@fluencelabs/fluence';
import { registerPrintln } from '../compiled/examples/println';
import { callArrowCall } from '../examples/callArrowCall';
import {callArrowCall, reproArgsBug426Call} from '../examples/callArrowCall';
import { dataAliasCall } from '../examples/dataAliasCall';
import { onCall } from '../examples/onCall';
import { funcCall } from '../examples/funcCall';
@ -73,6 +73,12 @@ describe('Testing examples', () => {
expect(callArrowResult).toBe('Hello, callArrow call!');
});
it('callArrow.aqua args bug 426', async () => {
let argResult = await reproArgsBug426Call();
expect(argResult).toBe("privet");
});
it('streamRestrictions.aqua', async () => {
let streamResResult = await streamResCall();

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.6.0-263
* Aqua version: 0.6.0-SNAPSHOT
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
@ -137,3 +137,83 @@ export function passFunctionAsArg(...args: any) {
script
)
}
export function reproArgsBug426(
log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>,
arg: string,
config?: {ttl?: number}
): Promise<void>;
export function reproArgsBug426(
peer: FluencePeer,
log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>,
arg: string,
config?: {ttl?: number}
): Promise<void>;
export function reproArgsBug426(...args: any) {
let script = `
(xor
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("getDataSrv" "arg") [] arg)
)
(xor
(call %init_peer_id% ("callbackSrv" "log") [arg])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
`
return callFunction(
args,
{
"functionName" : "reproArgsBug426",
"returnType" : {
"tag" : "void"
},
"argDefs" : [
{
"name" : "log",
"argType" : {
"tag" : "callback",
"callback" : {
"argDefs" : [
{
"name" : "arg0",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "void"
}
}
}
},
{
"name" : "arg",
"argType" : {
"tag" : "primitive"
}
}
],
"names" : {
"relay" : "-relay-",
"getDataSrv" : "getDataSrv",
"callbackSrv" : "callbackSrv",
"responseSrv" : "callbackSrv",
"responseFnName" : "response",
"errorHandlingSrv" : "errorHandlingSrv",
"errorFnName" : "error"
}
},
script
)
}

View File

@ -1,5 +1,5 @@
import { Fluence } from '@fluencelabs/fluence';
import { passFunctionAsArg } from '../compiled/examples/callArrow';
import {passFunctionAsArg, reproArgsBug426} from '../compiled/examples/callArrow';
export async function callArrowCall(): Promise<string> {
const relayPeerId = Fluence.getPeer().getStatus().relayPeerId;
@ -11,3 +11,12 @@ export async function callArrowCall(): Promise<string> {
}, {ttl: 10000});
});
}
export async function reproArgsBug426Call(): Promise<string> {
const relayPeerId = Fluence.getPeer().getStatus().relayPeerId;
return new Promise<string>((resolve, reject) => {
reproArgsBug426((a: string) => {
resolve(a);
}, "privet");
});
}