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

Does return only return a single 256 bit word? #71

Open
nejucomo opened this issue Mar 20, 2015 · 4 comments
Open

Does return only return a single 256 bit word? #71

nejucomo opened this issue Mar 20, 2015 · 4 comments

Comments

@nejucomo
Copy link

Note: The example uses serpent on the develop branch with revision c9563cff.

The following example tries to return a long text string. An examination of the LLL output makes it seem as if only 32 bytes are returned in the expression (return (ref '_temp_131) 32). Am I misreading this LLL expression?

$ cat > long_string_return.se
return text("This is 53 characters, which is longer than 256 bits.")

$ serpent compile_to_lll !$
serpent compile_to_lll long_string_return.se
(return 0
  (lll
    (seq
      (set '_temp_131
        (with '_temp17_str (alloc 85)
          (seq
            (mstore (get '_temp17_str) 53)
            (mstore (add (get '_temp17_str) 32)
              38178759162904981153227459547417441039765882805204013944776380134389117973280
            )
            (mstore (add (get '_temp17_str) 64)
              49046669650839314774563824355363137219616139645592700948219339121638676365312
            )
            (add (get '_temp17_str) 32)
          )
        )
      )
      (return (ref '_temp_131) 32)
    )
    0
  )
)
@vbuterin
Copy link
Contributor

vbuterin commented Mar 21, 2015 via email

@ethers
Copy link
Member

ethers commented Jul 1, 2015

@nejucomo: pls close or reopen if still an issue

@nejucomo
Copy link
Author

nejucomo commented Oct 4, 2015

@ethers The answer isn't yet quite clear enough. Is this understanding correct:

  • The grammar production return <expr> :str will return a long-string assuming that <expr> evaluates to a long string value.
  • The <expr> in this case is the literal text("This is 53 characters, which is longer than 256 bits.") .

What happens if <expr> does not evaluate to a long string value? eg: return 42 :str ?

@ethers
Copy link
Member

ethers commented Oct 6, 2015

Hi @nejucomo I haven't tried return 42 :str
Something would not work somewhere, and the error provided may not be clear at all, so at this stage developer does have to be more careful about the types. If you prefer better typing, try Solidity, but when you opened this issue I would not have been surprised if Solidity wasn't able to do better than Serpent in this regard (returning a string). Serpent has its quirks but you may find it can still do some things that Solidity does not yet support.

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

No branches or pull requests

3 participants