-
Notifications
You must be signed in to change notification settings - Fork 3
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
Forbid duplicated function definition #150
Comments
Marked in code. I will have a look tomorrow. |
Potential SolutionUse the experimental Feature activation via: |
I think a simple |
But A |
You rightfully changed my mind a while back, when you proposed to have a compiler that runs on rust stable, and I still think that we should stick to it now that it is nightly-feature-free :) Also, I'm not very comfortable with returning a We could use the |
Fair enough and I agree with not wanting to use experimental features, particularly unstable ones. We could compare the insert methods return value and match it to see if it is not /// In the scopes.rs for Scopes type
pub fn add(&mut self, s: K, val: T) -> std::result::Result<(), String> {
match self.scopes.last_mut().unwrap().insert(s, val) {
Some(_) => { Err("Key already exists!".to_string()) },
None => { Ok(()) }
}
} Just not sure how to cascade the error properly. |
None working example of new `Scopes::add` for context.
I've checked it out, It's nice ! You can take example from the fn visit_identifier() on how to add a diagnostic to the context. I realize now that the resolver does not abort the analysis right away when an error diagnostic is pushed, but still try to resolve the rest of the program before printing the diags and halting, to maximize the fixes a developer could do before re-running the compiler again. |
None working example of new `Scopes::add` for context.
We currently don't fail if a function is defined twice.
We must.
The text was updated successfully, but these errors were encountered: