fn try_from(ast: &AST) -> TypeResult<Expected> {
        let ast = match &ast.node {
            Node::Block { statements } | Node::Script { statements } =>
                statements.last().unwrap_or(ast),
            _ => ast
        };

        let expect = match &ast.node {
            Node::Int { .. } | Node::ENum { .. } => Type { name: NameUnion::from(INT_PRIMITIVE) },
            Node::Real { .. } => Type { name: NameUnion::from(FLOAT_PRIMITIVE) },
            Node::Bool { .. } => Type { name: NameUnion::from(BOOL_PRIMITIVE) },
            Node::Str { .. } => Type { name: NameUnion::from(STRING_PRIMITIVE) },
            Node::Undefined => Nullable,
            Node::Underscore => ExpressionAny,
            _ => Expression { ast: ast.clone() }
        };

        Ok(Expected::new(&ast.pos, &expect))
    }
/// Creates Expected from AST.
///
/// If primitive or Constructor, constructs Type.
Creates Expected from AST.
If primitive or Constructor, constructs Type.
Creates Expected from AST . If primitive or Constructor constructs Type .
fn try_from(ast: &AST) -> TypeResult<Expected> {
        let ast = match &ast.node {
            Node::Block { statements } | Node::Script { statements } =>
                statements.last().unwrap_or(ast),
            _ => ast
        };
        let expect = match &ast.node {
            Node::Int { .. } | Node::ENum { .. } => Type { name: NameUnion::from(INT_PRIMITIVE) },
            Node::Real { .. } => Type { name: NameUnion::from(FLOAT_PRIMITIVE) },
            Node::Bool { .. } => Type { name: NameUnion::from(BOOL_PRIMITIVE) },
            Node::Str { .. } => Type { name: NameUnion::from(STRING_PRIMITIVE) },
            Node::Undefined => Nullable,
            Node::Underscore => ExpressionAny,
            _ => Expression { ast: ast.clone() }
        };
        Ok(Expected::new(&ast.pos, &expect))
    }
fn try_from ( ast : & AST ) -> TypeResult < Expected > { let ast = match & ast . node { Node :: Block { statements } | Node :: Script { statements } => statements . last ( ) . unwrap_or ( ast ) , _ => ast } ; let expect = match & ast . node { Node :: Int { .. } | Node :: ENum { .. } => Type { name : NameUnion :: from ( INT_PRIMITIVE ) } , Node :: Real { .. } => Type { name : NameUnion :: from ( FLOAT_PRIMITIVE ) } , Node :: Bool { .. } => Type { name : NameUnion :: from ( BOOL_PRIMITIVE ) } , Node :: Str { .. } => Type { name : NameUnion :: from ( STRING_PRIMITIVE ) } , Node :: Undefined => Nullable , Node :: Underscore => ExpressionAny , _ => Expression { ast : ast . clone ( ) } } ; Ok ( Expected :: new ( & ast . pos , & expect ) ) }
Creates Expected from AST.
Creates Expected from AST .
ast
&AST