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

Fixed the Incorrect error messages during compilation #3994. #4340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

big1oot
Copy link

@big1oot big1oot commented Oct 30, 2024

…build_IR

What I did

I updated issue in VariableDecl.validate() and update string formatting in build_IR codes.

How I did it

I cloned the repo and fixed that part of the code.

How to verify it

run pytest

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Improved: Updated VariableDecl.validate() to correctly use self._pretty_location() for consistent variable location formatting.
Fixed: Modified _CreateBase.build_IR to use an f-string in context.check_is_not_constant, ensuring self._id is properly displayed in error messages.

Cute Animal Picture

It's a cute piglet.
Put a link to a cute animal picture inside the parenthesis-->

@@ -1440,7 +1440,7 @@ def validate(self):

if not self.is_constant and self.value is not None:
raise VariableDeclarationException(
f"{self._pretty_location} variables cannot have an initial value", self.value
f"{self._pretty_location()} variables cannot have an initial value", self.value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not correct, _pretty_location is a property. try to compile eg c: uint256 = 1

@@ -1663,7 +1663,7 @@ class _CreateBase(BuiltinFunctionT):
@process_inputs
def build_IR(self, expr, args, kwargs, context):
# errmsg something like f"Cannot use {self._id} in pure fn"
context.check_is_not_constant(f"use {self._id}", expr)
context.check_is_not_constant(f"Error: {self._id} is not a constant")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not correct, check_is_not_constant takes 3 args, only 2 provided

see eg:

@pure
def foo(a: address):
    b: address = create_minimal_proxy_to(a)

@cyberthirst
Copy link
Collaborator

Hello, even if the fixes were made, I'm not sure this PR is relevant.

When #3994 was created, pretty_location was a function

and _CreateBase.build_IR didn't use f-string which is no longer the case

@big1oot
Copy link
Author

big1oot commented Nov 5, 2024 via email

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 this pull request may close these issues.

2 participants