mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2026-03-01 04:28:51 +00:00
Sequence points for some of RET statements are improperly generated #1393
Labels
No labels
I1
I2
I3
I4
S1
S2
S3
S4
U0
U1
U2
U3
U3
U4
blocked
bug
bug
cli
compiler
config
config
consensus
dependencies
discussion
documentation
enhancement
epic
feature
go
good first issue
help wanted
neotest
network
oracle
performance
question
rpc
security
smartcontract
task
task
task
test
vm
wallet
windows
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nspcc-dev/neo-go#1393
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AnnaShaleva on GitHub (Oct 17, 2024).
Current Behavior
For some RET instructions our compiler generates sequence points with improper boundaries, for example for void functions (if there's no explicit
returnkeyword in the code), also for functions with named parameters where explicitreturnkeyword is missing and may be for more cases that I'm not aware of (it needs to be investigated). The example of such function is given here: https://github.com/nspcc-dev/neo-go/issues/3559#issuecomment-2414148935.Improper boundaries of such sequence points include the whole function body, like it's described here: https://github.com/nspcc-dev/neo-go/pull/3617#issue-2592286954
One case is caused by this code (but there are probably more cases):
nspcc-dev/neo-go@86ed214e8a/pkg/compiler/codegen.go (L542-L543)This behaviour is invalid, because:
There are some
returnstatements that have proper boundaries of sequence points. For example, non-void functions wherereturnkeyword is explicitly present. It's becausereturnkeyword is properly handled by our compiler and sequence point is generated only for thereturnAST node:nspcc-dev/neo-go@14ea5a8d32/pkg/compiler/codegen.go (L755)nspcc-dev/neo-go@14ea5a8d32/pkg/compiler/codegen.go (L793)C# compiler properly handles the described case and generates
RETsequence points with short-range. Although it has slightly different behaviour in that it boundsRETopcodes to closing brackets of the corresponding functions (}). This behaviour is described here: https://github.com/nspcc-dev/neo-go/pull/3617#issuecomment-2419970469Expected Behavior
Boundaries of all sequence points corresponding to
RETopcodes must not have function-wide bounds.Possible Solution
Rework the way how sequence points generated for
RETopcodes. At least fix these "function-wide" sequence points. May be rework the whole scheme ofRETsequence points generation to make the behaviour similar to C# compiler.Additional context
Related to #3559 and #3617.