Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Using derived storage pointer instead of constant when passing as argument to macro breaks #234

Open
af-afk opened this issue Dec 28, 2022 · 2 comments

Comments

@af-afk
Copy link

af-afk commented Dec 28, 2022

The following snippets are identical in theory:

#define constant SWAG = 0x00

#define macro M(slot) = {
	<slot> sload 0x00 mstore 0x14 0x00 return
}

#define macro MAIN() = {
	M(SWAG)
}
#define constant SWAG = FREE_STORAGE_POINTER()

#define macro M(slot) = {
	<slot> sload 0x00 mstore 0x14 0x00 return
}

#define macro MAIN() = {
	M(SWAG)
}

But the latter errors without context with Error: Storage Pointers Not Derived.

Seems to be a bug?

@af-afk
Copy link
Author

af-afk commented Dec 29, 2022

The macro TEST will not insert SLOT_SOMETHING into the stack (silently fail) if it's referred to this way:

#define constant SLOT_SOMETHING = FREE_STORAGE_POINTER()

#define macro TEST() = {
	0x01

	<SLOT_SOMETHING> sstore
}

#define macro MAIN() = {
	TEST()
}

Generating bytecode 60038060093d393df3600155. Having SLOT_SOMETHING be accessed with [SLOT_SOMETHING] instead means 60058060093d393df36001600055.

Doing this in MAIN is a different story:

#define constant SLOT_SOMETHING = FREE_STORAGE_POINTER()

#define macro MAIN() = {
	0x01

	<SLOT_SOMETHING> sstore
}

In the above example it fails with:

�[31m
Error: Unmatched Jump Label

�[0m
huffc: exit 1

@Maddiaa0
Copy link
Member

The original issue has been merged in, could you make the second comment into another issue please so its easier to triage! Appreciate you finding these issues :):)

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

No branches or pull requests

2 participants