Skip to content

Commit

Permalink
fix: error when getting state in multi-line function call
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-p committed Jul 8, 2024
1 parent d8f63c1 commit 5ce80f9
Show file tree
Hide file tree
Showing 6 changed files with 646 additions and 417 deletions.
12 changes: 10 additions & 2 deletions src/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,11 @@ export default class Compiler {
node,
'app_global_get_ex',
StackType.any,
`global state value does not exist: ${node.getText()}`
`global state value does not exist: ${node
.getText()
.split('\n')
.map((l) => l.trim())
.join(' ')}`
);
},
},
Expand All @@ -681,7 +685,11 @@ export default class Compiler {
node,
'app_local_get_ex',
StackType.any,
`local state value does not exist: ${node.getText()}`
`local state value does not exist: ${node
.getText()
.split('\n')
.map((l) => l.trim())
.join(' ')}`
);
},
},
Expand Down
42 changes: 41 additions & 1 deletion tests/contracts/artifacts/GeneralTest.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,45 @@ nonAbi:
*for_1_end:
retsub

// multilineFunctionCall()void
*abi_route_multilineFunctionCall:
// execute multilineFunctionCall()void
callsub multilineFunctionCall
int 1
return

// multilineFunctionCall(): void
multilineFunctionCall:
proto 0 0

// Push empty bytes after the frame pointer to reserve space for local variables
byte 0x
dup

// tests/contracts/general.algo.ts:517
// app = AppID.zeroIndex
int 0
frame_bury 0 // app: uint64

// tests/contracts/general.algo.ts:518
// addr = Address.zeroAddress
global ZeroAddress
frame_bury 1 // addr: address

// tests/contracts/general.algo.ts:520
// app.localState(
// addr,
// 'key'
// )
frame_dig 1 // addr: address
int 0 // app: uint64
byte 0x6b6579 // "key"
app_local_get_ex

// local state value does not exist: app.localState( addr, 'key' )
assert
retsub

*abi_route_createApplication:
int 1
return
Expand Down Expand Up @@ -2744,8 +2783,9 @@ nonAbi:
method "assertComment()void"
method "throwErrorMessage()void"
method "orLiteralType(uint64,uint64)void"
method "multilineFunctionCall()void"
txna ApplicationArgs 0
match *abi_route_txnTypeEnum *abi_route_txnGroupLength *abi_route_asserts *abi_route_verifyTxnFromArg *abi_route_verifyTxnFromTxnGroup *abi_route_verifyTxnCondition *abi_route_verifyTxnIncludedIn *abi_route_verifyTxnNotIncludedIn *abi_route_submitPendingGroup *abi_route_methodWithTxnArgs *abi_route_shift *abi_route_fromBytes *abi_route_fromUint64 *abi_route_bzeroFunction *abi_route_events *abi_route_letOptimization *abi_route_staticContractProperties *abi_route_numberToString *abi_route_methodOnParens *abi_route_stringSubstring *abi_route_idProperty *abi_route_scratchSlot *abi_route_ecdsa *abi_route_verifyTxnTypes *abi_route_stringPlusEquals *abi_route_importedProgram *abi_route_callPrivateDefinedLater *abi_route_interalPublicMethod *abi_route_callInternalPublicMethod *abi_route_appLoadScratch *abi_route_uintNWithUnderscore *abi_route_opUp *abi_route_returnValueOnAssignment *abi_route_returnArrayValueOnAssignment *abi_route_returnStorageValueOnAssignment *abi_route_returnOperatorAssignmentValue *abi_route_returnArrayValueOnOperatorAssignment *abi_route_returnArrayInStorageValueOnOperatorAssignment *abi_route_consts *abi_route_assertWithMessage *abi_route_opcodeAliases *abi_route_vrfVerifyOp *abi_route_ecMath *abi_route_gitxn *abi_route_getSetBytes *abi_route_getSetUint64 *abi_route_blockOp *abi_route_b64 *abi_route_json *abi_route_bitlenOp *abi_route_computedConst *abi_route_multiComputedConst *abi_route_readSchema *abi_route_comparisonOr *abi_route_txnArgsMethod *abi_route_callTxnArgsMethod *abi_route_staticValueLen *abi_route_staticTypeLen *abi_route_dynamicScratchSlot *abi_route_incrementScratchSlot *abi_route_incrementDynamicScratchSlot *abi_route_fromAddress *abi_route_earlyReturn *abi_route_assetMethodArgs *abi_route_multipleProgramPages *abi_route_assertComment *abi_route_throwErrorMessage *abi_route_orLiteralType
match *abi_route_txnTypeEnum *abi_route_txnGroupLength *abi_route_asserts *abi_route_verifyTxnFromArg *abi_route_verifyTxnFromTxnGroup *abi_route_verifyTxnCondition *abi_route_verifyTxnIncludedIn *abi_route_verifyTxnNotIncludedIn *abi_route_submitPendingGroup *abi_route_methodWithTxnArgs *abi_route_shift *abi_route_fromBytes *abi_route_fromUint64 *abi_route_bzeroFunction *abi_route_events *abi_route_letOptimization *abi_route_staticContractProperties *abi_route_numberToString *abi_route_methodOnParens *abi_route_stringSubstring *abi_route_idProperty *abi_route_scratchSlot *abi_route_ecdsa *abi_route_verifyTxnTypes *abi_route_stringPlusEquals *abi_route_importedProgram *abi_route_callPrivateDefinedLater *abi_route_interalPublicMethod *abi_route_callInternalPublicMethod *abi_route_appLoadScratch *abi_route_uintNWithUnderscore *abi_route_opUp *abi_route_returnValueOnAssignment *abi_route_returnArrayValueOnAssignment *abi_route_returnStorageValueOnAssignment *abi_route_returnOperatorAssignmentValue *abi_route_returnArrayValueOnOperatorAssignment *abi_route_returnArrayInStorageValueOnOperatorAssignment *abi_route_consts *abi_route_assertWithMessage *abi_route_opcodeAliases *abi_route_vrfVerifyOp *abi_route_ecMath *abi_route_gitxn *abi_route_getSetBytes *abi_route_getSetUint64 *abi_route_blockOp *abi_route_b64 *abi_route_json *abi_route_bitlenOp *abi_route_computedConst *abi_route_multiComputedConst *abi_route_readSchema *abi_route_comparisonOr *abi_route_txnArgsMethod *abi_route_callTxnArgsMethod *abi_route_staticValueLen *abi_route_staticTypeLen *abi_route_dynamicScratchSlot *abi_route_incrementScratchSlot *abi_route_incrementDynamicScratchSlot *abi_route_fromAddress *abi_route_earlyReturn *abi_route_assetMethodArgs *abi_route_multipleProgramPages *abi_route_assertComment *abi_route_throwErrorMessage *abi_route_orLiteralType *abi_route_multilineFunctionCall

// !!!! WARNING: non-ABI routing
callsub nonAbi
Expand Down
14 changes: 13 additions & 1 deletion tests/contracts/artifacts/GeneralTest.arc32.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions tests/contracts/artifacts/GeneralTest.arc4.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,13 @@
"type": "void"
}
},
{
"name": "multilineFunctionCall",
"args": [],
"returns": {
"type": "void"
}
},
{
"name": "createApplication",
"args": [],
Expand Down
Loading

0 comments on commit 5ce80f9

Please sign in to comment.