feat: field access

This commit is contained in:
rvcas
2022-10-02 18:16:19 -04:00
committed by Lucas
parent 34492f600c
commit 1b61f4b25b
2 changed files with 98 additions and 2 deletions

View File

@@ -77,6 +77,10 @@ fn module() {
}
fn run() {}
fn name(user: User) {
user.name
}
"#;
let len = code.chars().count();
@@ -725,6 +729,36 @@ fn module() {
return_annotation: None,
return_type: (),
},
ast::UntypedDefinition::Fn {
arguments: vec![ast::Arg {
arg_name: ast::ArgName::Named {
name: "user".to_string(),
location: Span::new(SrcId::empty(), 1425..1429),
},
location: Span::new(SrcId::empty(), 1425..1435),
annotation: Some(ast::Annotation::Constructor {
location: Span::new(SrcId::empty(), 1431..1435),
module: None,
name: "User".to_string(),
arguments: vec![],
},),
tipo: (),
},],
body: expr::UntypedExpr::FieldAccess {
location: Span::new(SrcId::empty(), 1455..1464),
label: "name".to_string(),
container: Box::new(expr::UntypedExpr::Var {
location: Span::new(SrcId::empty(), 1455..1459),
name: "user".to_string(),
}),
},
doc: None,
location: Span::new(SrcId::empty(), 1417..1478),
name: "name".to_string(),
public: false,
return_annotation: None,
return_type: (),
},
]
},
);