Add public visibility modifier for contract functions#434
Open
axic wants to merge 3 commits into
Open
Conversation
Contributor
Author
|
I'll rebase this once fallback is merged. |
6f89ae4 to
b1e0716
Compare
Contributor
Author
|
@rodrigogribeiro @mbenke this should be ready now |
Functions in a contract are now private by default; only those marked with the new `public` keyword preceding `function` are exposed through the runtime dispatcher (and get a generated `SigString` instance). - `FunDef` carries a `funIsPublic :: Bool` field threaded through parsing, name resolution, type inference, specialisation and pretty-printing. - Parser accepts an optional `public` keyword before `function`; `public` is now a reserved word. - `ContractDispatch` filters the dispatch method tuple and selector data types to public functions only. Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
Updates every `.solc` test fixture (and example std imports) so each
function defined inside a `contract { ... }` block is prefixed with
the new `public` keyword. Top-level functions, class methods, and
instance methods are left untouched since the visibility modifier
only applies to contract members.
Also adds a `hidden()` non-public method to dispatch/basic.solc and a
corresponding basic.json test case verifying its selector (aef6d4b1)
falls through to the missing-fallback error (4924aef0) instead of
being dispatched.
Both are implicitly public — the dispatch entry point always invokes them, so writing `public fallback()` or `public constructor()` is misleading. Detect this in the contract-declaration parser and emit a clear error instead of the confusing parse failure that came out before. Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a
contractevery function is private, unless marked aspublic. Special cases:constructorandfallbackare always considered public, but the keyword is not needed to be present (if fact it can't be).