pub fn check(node: walk::Node) -> Result<(), Errors<Error>> {
    let mut errors = Errors::new();
    walk::walk(
        &walk::create_visitor(&mut |n| {
            // collect any errors we found prior to ast.check().
            for err in n.base().errors.iter() {
                errors.push(located(
                    n.base().location.clone(),
                    ErrorKind {
                        message: err.clone(),
                    },
                ));
            }

            match *n {
                walk::Node::BadStmt(n) => errors.push(located(
                    n.base.location.clone(),
                    ErrorKind {
                        message: format!("invalid statement: {}", n.text),
                    },
                )),
                walk::Node::BadExpr(n) if !n.text.is_empty() => errors.push(located(
                    n.base.location.clone(),
                    ErrorKind {
                        message: format!("invalid expression: {}", n.text),
                    },
                )),
                walk::Node::ObjectExpr(n) => {
                    let mut has_implicit = false;
                    let mut has_explicit = false;
                    for p in n.properties.iter() {
                        if p.base.errors.is_empty() {
                            match p.value {
                                None => {
                                    has_implicit = true;
                                    if let PropertyKey::StringLit(s) = &p.key {
                                        errors.push(located(
                                            n.base.location.clone(),
                                            ErrorKind {
                                                message: format!(
                                                    "string literal key {} must have a value",
                                                    s.value
                                                ),
                                            },
                                        ))
                                    }
                                }
                                Some(_) => {
                                    has_explicit = true;
                                }
                            }
                        }
                    }
                    if has_implicit && has_explicit {
                        errors.push(located(
                            n.base.location.clone(),
                            ErrorKind {
                                message: String::from(
                                    "cannot mix implicit and explicit properties",
                                ),
                            },
                        ))
                    }
                }
                _ => {}
            }
        }),
        node,
    );
    if errors.is_empty() {
        Ok(())
    } else {
        Err(errors)
    }
}
/// Inspects an AST node and returns a list of found AST errors plus
/// any errors existed before `ast.check()` is performed.
Inspects an AST node and returns a list of found AST errors plus
any errors existed before `ast.check()` is performed.
Inspects an AST node and returns a list of found AST errors plus any errors existed before ` ast . check () ` is performed .
pub fn check(node: walk::Node) -> Result<(), Errors<Error>> {
    let mut errors = Errors::new();
    walk::walk(
        &walk::create_visitor(&mut |n| {
            // collect any errors we found prior to ast.check().
            for err in n.base().errors.iter() {
                errors.push(located(
                    n.base().location.clone(),
                    ErrorKind {
                        message: err.clone(),
                    },
                ));
            }
            match *n {
                walk::Node::BadStmt(n) => errors.push(located(
                    n.base.location.clone(),
                    ErrorKind {
                        message: format!("invalid statement: {}", n.text),
                    },
                )),
                walk::Node::BadExpr(n) if !n.text.is_empty() => errors.push(located(
                    n.base.location.clone(),
                    ErrorKind {
                        message: format!("invalid expression: {}", n.text),
                    },
                )),
                walk::Node::ObjectExpr(n) => {
                    let mut has_implicit = false;
                    let mut has_explicit = false;
                    for p in n.properties.iter() {
                        if p.base.errors.is_empty() {
                            match p.value {
                                None => {
                                    has_implicit = true;
                                    if let PropertyKey::StringLit(s) = &p.key {
                                        errors.push(located(
                                            n.base.location.clone(),
                                            ErrorKind {
                                                message: format!(
                                                    "string literal key {} must have a value",
                                                    s.value
                                                ),
                                            },
                                        ))
                                    }
                                }
                                Some(_) => {
                                    has_explicit = true;
                                }
                            }
                        }
                    }
                    if has_implicit && has_explicit {
                        errors.push(located(
                            n.base.location.clone(),
                            ErrorKind {
                                message: String::from(
                                    "cannot mix implicit and explicit properties",
                                ),
                            },
                        ))
                    }
                }
                _ => {}
            }
        }),
        node,
    );
    if errors.is_empty() {
        Ok(())
    } else {
        Err(errors)
    }
}
pub fn check ( node : walk :: Node ) -> Result < ( ) , Errors < Error > > { let mut errors = Errors :: new ( ) ; walk :: walk ( & walk :: create_visitor ( & mut | n | { // collect any errors we found prior to ast.check(). for err in n . base ( ) . errors . iter ( ) { errors . push ( located ( n . base ( ) . location . clone ( ) , ErrorKind { message : err . clone ( ) , } , ) ) ; } match * n { walk :: Node :: BadStmt ( n ) => errors . push ( located ( n . base . location . clone ( ) , ErrorKind { message : format ! ( " " n text ) , } , ) ) , walk :: Node :: BadExpr ( n ) if ! n . text . is_empty ( ) => errors . push ( located ( n . base . location . clone ( ) , ErrorKind { message : format ! ( " " n text ) , } , ) ) , walk :: Node :: ObjectExpr ( n ) => { let mut has_implicit = false ; let mut has_explicit = false ; for p in n . properties . iter ( ) { if p . base . errors . is_empty ( ) { match p . value { None => { has_implicit = true ; if let PropertyKey :: StringLit ( s ) = & p . key { errors . push ( located ( n . base . location . clone ( ) , ErrorKind { message : format ! ( " " s value ) , } , ) ) } } Some ( _ ) => { has_explicit = true ; } } } } if has_implicit && has_explicit { errors . push ( located ( n . base . location . clone ( ) , ErrorKind { message : String :: from ( " " , ) , } , ) ) } } _ => { } } } ) , node , ) ; if errors . is_empty ( ) { Ok ( ( ) ) } else { Err ( errors ) } }
Inspects an AST node and returns a list of found AST errors plus
any errors existed before `ast.check()` is performed.
Inspects an AST node and returns a list of found AST errors plus any errors existed before ` ast . check () ` is performed .
node
walk::Node
node
walk::Node