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

[todo]: refactoring - duplicate function call cause duplicate error at interface decl statement #1104

Open
sunrabbit123 opened this issue Nov 14, 2023 · 0 comments

Comments

@sunrabbit123
Copy link
Collaborator

#[validator]
impl Analyzer<'_, '_> {
    fn validate(&mut self, d: &RTsInterfaceDecl) -> VResult<Type> {
        let ty = self.with_child(ScopeKind::Flow, Default::default(), |child: &mut Analyzer| -> VResult<_> {
            match &*d.id.sym {
                "any" | "void" | "never" | "unknown" | "string" | "number" | "bigint" | "boolean" | "null" | "undefined" | "symbol" => {
                    child.storage.report(ErrorKind::InvalidInterfaceName { span: d.id.span }.into());
                }
                _ => {}
            }

            let mut ty = Interface {
                span: d.span,
                name: d.id.clone().into(),
                type_params: try_opt!(d.type_params.validate_with(&mut *child).map(|v| v.map(Box::new))),
                extends: d.extends.validate_with(child)?.freezed(),
                body: d.body.validate_with(child)?,
                metadata: Default::default(),
                tracker: Default::default(),
            };
            child.prevent_expansion(&mut ty.body);
            ty.body.freeze();

            child.resolve_parent_interfaces(&d.extends, true); // this 
            child.report_error_for_conflicting_parents(d.id.span, &ty.extends);
            child.report_error_for_wrong_interface_inheritance(d.id.span, &ty.body, &ty.extends); // this

            let ty = Type::Interface(ty).freezed();

            Ok(ty)
        })?;

        // TODO(kdy1): Recover
        self.register_type(d.id.clone().into(), ty.clone());

        Ok(ty)
    }
}

related issue
#1103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant