Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always return a value for public methods #300

Closed
Tommo-L opened this issue Jun 21, 2020 · 5 comments · Fixed by #327
Closed

Always return a value for public methods #300

Tommo-L opened this issue Jun 21, 2020 · 5 comments · Fixed by #327

Comments

@Tommo-L
Copy link
Contributor

Tommo-L commented Jun 21, 2020

apply neo-project/neo#1706

  • When create a public void method, compiler may return a Null.
  • When call a void method, compiler need to drop the top value on the stack.

We may need to know the ABI of the invoked contract.

@erikzhang
Copy link
Member

When create a public void method, compiler may return a Null.

This is wrong.

@Tommo-L
Copy link
Contributor Author

Tommo-L commented Jun 21, 2020

Has already returned a null value in neo-core?

// neo.SmartContract.ApplicationEngine.cs
protected override void ContextUnloaded(ExecutionContext context)
{
      base.ContextUnloaded(context);
      if (CurrentContext != null && context.EvaluationStack != CurrentContext.EvaluationStack)
          if (context.EvaluationStack.Count == 0)
              Push(StackItem.Null);
}

@shargon
Copy link
Member

shargon commented Jun 21, 2020

Yes, we already return a null item with void

@ShawnYun
Copy link
Contributor

ShawnYun commented Jul 3, 2020

But how does the compiler know the return type of the calling contract.

@erikzhang
Copy link
Member

See neo-project/neo#1680 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants