Comments (9)
Names should be restricted to the following forms:
Foo - public type
_Foo - private type
foo - public non-type
_foo - private non-type
In particular leading double underscore or underscore followed by a digit are not allowed.
The lexer should just accept all of these and the correctness pass should verify them.
from ponyc.
What about structural types and private methods? Obviously, this isn't an issue for private fields, but for methods, there is no way to determine which package a type that has been passed as a structural type was defined in (other than with an runtime check, which isn't what we're looking for).
That means a structural type can expose private methods outside the package.
Should we disallow private methods in structural types? I'm thinking yes, we should. That way, anonymous types never expose access to class internals.
from ponyc.
I've put this in as denying private method lookup on structural types. We can revisit this later if we need to, of course.
from ponyc.
I agree, structural types should not have private methods. A structural type is an inteface, just like a trait, so they don't need private methods which are internal.
from ponyc.
Ok, great. Right now, it only catches that on lookup. Should we be more aggressive, and disallow it when the structural type is defined?
from ponyc.
I agree on this. Generally, if think type checking should always be as aggressive as possible. There is no point it seemingly allowing the declaration/definition, but then throw an error on lookup.
from ponyc.
We should definitely be more aggressive on this. It would be easy to check structural types (and also traits) for private methods in either the parse_fix or scope passes. Scope probably makes more sense logically.
from ponyc.
Ok sounds good. Andy, can you handle it?
from ponyc.
I handled it in the scope pass.
from ponyc.
Related Issues (20)
- Feat: Reconsider support for ponyc bundled builds targeting Intel MacOS HOT 1
- runaway memory growth during GC with reference cycle HOT 12
- RFC #77: Assign Param Syntax
- RFC #78: Remove JSON package from the standard library
- Can't built 0.53.0 on aarch64-darwin HOT 8
- Possible violation of the `pthread_create` interface? HOT 4
- Release 0.54.1 HOT 2
- iftype compile error at runtime HOT 7
- [Epic] EL 9 & Fedora support - prebuilt, install.md, and ponyup HOT 1
- XorOshiro naming in random HOT 2
- Incorrect program result when not using --debug HOT 16
- Release 0.55.0
- Segmentation fault when capturing Env via lambda HOT 17
- Segfault when trying to compile incorrect capabilities HOT 12
- With block doesn't call dispose on an object if its name is _ HOT 7
- Web assembly
- Unreported type inference error with Array's in match case statements HOT 9
- Cannot build with --static nor --nopic. HOT 7
- Release 0.55.1 HOT 1
- How to cross compile for armv7? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ponyc.