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

feat: support type infer for class memeber #2880

Closed
wants to merge 4 commits into from

Conversation

HerrCai0907
Copy link
Member

@HerrCai0907 HerrCai0907 commented Oct 28, 2024

It introduce a new internal mechanism in resolver to infer the expression type without Flow. Just like decltype() in C++ to support more flexible class definition.

@CountBleck
Copy link
Member

CountBleck commented Oct 29, 2024 via email

@HerrCai0907
Copy link
Member Author

HerrCai0907 commented Oct 29, 2024

Adding a new AST node just for this, and then creating a type from it based off of the NodeKind​ of the expression

We definitely need a node like CompiledExpression in type side to support type infer (not only for this PR, it is only the first application of this kind of node) which has syntax that user does not give the type name but compiler can infer this type.

We have 2 solutions. one is InferredType in this PR, the other is a TypeNode which contains Type directly. Which do you think is better.

I think InferredType is better than the other solution because it is more powerful which can also support generic also. At most of time, missed type should be inferred from a expression, and expression is also AST node, it can keep the compiler layers are not coupled to each other.

@HerrCai0907
Copy link
Member Author

@CountBleck WDYT?

@HerrCai0907 HerrCai0907 marked this pull request as ready for review November 2, 2024 06:18
@CountBleck
Copy link
Member

CountBleck commented Nov 3, 2024 via email

@HerrCai0907
Copy link
Member Author

I agree with you. Then the question is should we follow the current design and patch the AST / Resolver / Compiler to do type inferring or we design a new mechanism and introduce new process during compilation. It may introduce a huge change for Class and Function elements.

@HerrCai0907 HerrCai0907 closed this Nov 5, 2024
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