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

LLL: support symbols in the LIT keyword #1188

Closed
zigguratt opened this issue Oct 10, 2016 · 6 comments
Closed

LLL: support symbols in the LIT keyword #1188

zigguratt opened this issue Oct 10, 2016 · 6 comments

Comments

@zigguratt
Copy link
Contributor

The lit keyword works as expected when used inline:

(sha3 0x00 (lit 0x00 "Initialized(bool)"))

As with any LLL keyword, lit should be usable in a macro:

(def 'keccak (input)
  (sha3 0x00 (lit 0x00 input)))

However, when the keccak macro is subsequently invoked:

(keccak "Initialized(bool)")

the compiler produces this error:

Parse error.
/tmp/cpp-ethereum-20160629-19326-1m7sp55/solidity/liblll/CodeFragment.h(53): Throw in function void dev::eth::CodeFragment::error() const [T = dev::eth::InvalidLiteral]
Dynamic exception type: boost::exception_detail::clone_impl<dev::eth::InvalidLiteral>
std::exception::what: std::exception
@axic axic added the bug 🐛 label Oct 10, 2016
@axic
Copy link
Member

axic commented Oct 13, 2016

Is it happening in every case or certain cases only? Do you need some help tracking it down?

@zigguratt
Copy link
Contributor Author

zigguratt commented Oct 14, 2016

The error happens in all cases where lit is executed in a def and a string literal is expected. I haven't tested other input types. The lit docs describe three possible input literal types. This fails in a def macro because I believe the lit handler doesn't expect the type of input provided to it by def.

I'm not yet familiar enough with the liblll C++ source to be able to follow the trail effectively so yes, help tracking it down would be greatly appreciated. The lit handler is at line 274 of CodeFragment.cpp, and def is at line 225. I'll continue to try to figure it out as well.

Thanks, @axic!

@zigguratt
Copy link
Contributor Author

I would normally look through the assembly code produced by the compiler to see what lit is getting, but the error prevents the assembly code from being generated.

@zigguratt
Copy link
Contributor Author

A quick update: I just tested the other two types of input to lit in a macro and they both fail in the same way. So it's not specific to string literals.

@zigguratt
Copy link
Contributor Author

Actually, I'd like to try to figure this out myself for a bit longer. There's no huge hurry and it would be good for me to get more familiar with the code anyway. I appreciate the offer of help and I'll probably take you up on it in the near future.

Thanks again, @axic!

@zigguratt
Copy link
Contributor Author

It's not looking good for being able to fix this bug. @axic and I have looked in-depth at the lit code in the compiler. Having to look up symbols at compile time is a problem because, according to @axic, "the whole compiler works on the assumption that everything is evaluated runtime and no instructions are there to be evaluated an compile time".

That makes sense. Sadly, it introduces a situation where a legitimate LLL keyword can't be used in a macro because in that context it gets a symbol as input, which would require a compile-time evaluation.

@axic axic added enhancement and removed bug 🐛 labels Nov 21, 2016
@axic axic changed the title LLL: LIT keyword fails when used in a macro. LLL: support symbols in the LIT keyword Nov 21, 2016
@axic axic added feature and removed enhancement labels Oct 6, 2017
veox added a commit to veox/populus that referenced this issue Dec 11, 2017
There's something I don't understand yet: when running `pytest`,
Populus can't decode the return value.

It seems that the HeadTail decoder (from `eth_abi`) gets a
bogus stream, where `seek` is a huge (32 bytes?) number that looks
like a hash. Perhaps this is related to

ethereum/solidity#1188

or perhaps, when storing/retrieving a string, some particular
encoding scheme has to be used.

I've tried many approaches (none of them are recorded in git
history), but none worked.

Therefore, resorting to using a simpler contract.
veox added a commit to veox/populus that referenced this issue Dec 11, 2017
There's something I don't understand yet: when running `pytest`,
Populus can't decode the return value.

It seems that the HeadTail decoder (from `eth_abi`) gets a
bogus stream, where `seek` is a huge (32 bytes?) number that looks
like a hash. Perhaps this is related to

ethereum/solidity#1188

or perhaps, when storing/retrieving a string, some particular
encoding scheme has to be used.

I've tried many approaches (none of them are recorded in git
history), but none worked.

Therefore, resorting to using a simpler contract.

SQUASHED:

Greeter.lll: remove NIHLIB populus-end marker.

Literals are hard. For now, won't support them.

Depending on where in code they appear (deployment or runtime
code), and whether the `lit` keyword is used to define a macro,
it's difficult to determine if they have to be stripped.

Greeter.lll: minor, remove warning comment: now tested.
veox added a commit to veox/populus that referenced this issue Dec 11, 2017
There's something I don't understand yet: when running `pytest`,
Populus can't decode the return value.

It seems that the HeadTail decoder (from `eth_abi`) gets a
bogus stream, where `seek` is a huge (32 bytes?) number that looks
like a hash. Perhaps this is related to

ethereum/solidity#1188

or perhaps, when storing/retrieving a string, some particular
encoding scheme has to be used.

I've tried many approaches (none of them are recorded in git
history), but none worked.

Therefore, resorting to using a simpler contract.
@axic axic mentioned this issue Dec 10, 2019
6 tasks
@axic axic closed this as completed Jan 15, 2020
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

2 participants