-
Notifications
You must be signed in to change notification settings - Fork 9
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
Validate define functions #404
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #404 +/- ##
==========================================
+ Coverage 86.95% 87.28% +0.33%
==========================================
Files 43 43
Lines 18325 18788 +463
Branches 18325 18788 +463
==========================================
+ Hits 15934 16400 +466
+ Misses 1051 1050 -1
+ Partials 1340 1338 -2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure this is the fix we want here.
If you look at the top of the file, you'll see that tools.rs only contains functions used during testing. So, your fix only works in a testing context.
@Acaccia is correct. Also, for an implementation in the Clarity VM this kind of fix will need to be epoch- and/or clarity version-gated as existing contracts which break this rule must still function exactly the same. |
Yes. I've looked at clarity VM code related to that. Thanks for reminding me. I'll take a deeper look again. |
The problem with It wasn't causing problem in bindings ("let" function) because "let" isn't a public function. Analysis pass takes care of name conflict issues like this
That's why I've commented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know what is happening here. Why was contract_analysis.get_public_function_type()
called there? Why is it safe to remove it? This function was already used for checking bindings, can it be used with the same rules for other-thingies definitions?
Also, you did not address @cylewitruk remark about Clarity version or epoch.
For example, (define-private (index-of?) (ok u0))
would work in Clarity 1 but not in Clarity 2.
@krl wrote this method and added
If you take a look at
during analysis pass, clarity function name, If the reason to call this method was to check if custom method is re-defined second time with same name, this doesn't seem the right approach. It occurred to me that analysis pass already takes care of that conflict problem and we don't need that check. If you take a look at tests, they contain conflicted names, and compiler's and interpreter's results are matching. In bindings, it wasn't causing any problem because |
Regarding epoch comment, I want to ask something. There's a method called |
I'm getting default Clarity version for a given epoch. I suppose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good, but I'm not entirely sure I perfectly understood the issue with get_public_function_type
. So maybe @krl should actually validate this?
However, I have an issue with the usage of crosscheck_compare_only
. When it is easy to determine the output of a snippet, we should check that it corresponds to our expectation. It's also easier for someone who will read your tests later to know which tests should work and which are expected to fail.
requested changes made :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few remarks about the naming.
Also I remark that there are tests with different Epochs only for the function definition functions. Shouldn't there be some for the other kind of defines?
@Acaccia could you give it a look again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
This PR fixes #391