Git Product home page Git Product logo

Comments (5)

EmelyanenkoK avatar EmelyanenkoK commented on August 29, 2024 1

It is funC related behavior, not TVM/sandbox.
The thing is that load_ref is considered pure (while actually it can be impure if throw exception). In other words funC drops load_ref operation if result is not used:
Both

;; This will throw an error, as expected (assuming the slice doesn't in fact contain a ref)
() recv_external(slice in_msg) impure {
  var x = in_msg~load_ref();
  accept_message();
}

and

;; This will NOT throw an error
() recv_external(slice in_msg) impure {
  accept_message();
  var x = in_msg~load_ref();
}

will compile to

recv_external PROC:<{
  DROP
  ACCEPT
}>

from sandbox.

shaharyakir avatar shaharyakir commented on August 29, 2024

This explains why the error isn't thrown when the loaded ref isn't used.

But in this case:

() recv_external(slice in_msg) impure {
  accept_message();
  var x = in_msg~load_ref();
  ~dump x;
}

The value is used. Shouldn't an error be thrown then?

from sandbox.

EmelyanenkoK avatar EmelyanenkoK commented on August 29, 2024
() recv_external(slice in_msg) impure {
  accept_message();
  var x = in_msg~load_ref();
  ~dump x;
}

compiles to

recv_external PROC:<{
  ACCEPT
  LDREF
  DROP
  s0 DUMP
  DROP
}>

so yes, I'm expecting failed transaction in this case

from sandbox.

krigga avatar krigga commented on August 29, 2024

This explains why the error isn't thrown when the loaded ref isn't used.

But in this case:

() recv_external(slice in_msg) impure {
  accept_message();
  var x = in_msg~load_ref();
  ~dump x;
}

The value is used. Shouldn't an error be thrown then?

With this code, I'm getting exit code 9 (to be expected). Do you get the same result?

from sandbox.

shaharyakir avatar shaharyakir commented on August 29, 2024

I'll check, it was probably a misunderstanding of mine of how errors work before and after accepting messages. will reopen issue if needed

from sandbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.