1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
// SPDX-License-Identifier: Apache-2.0
use crate::sema::ast::{
ArrayLength, Builtin, Expression, Namespace, RetrieveType, StructType, Symbol, Type,
};
use crate::sema::builtin;
use crate::sema::diagnostics::Diagnostics;
use crate::sema::expression::constructor::circular_reference;
use crate::sema::expression::function_call::function_type;
use crate::sema::expression::integers::bigint_to_expression;
use crate::sema::expression::resolve_expression::expression;
use crate::sema::expression::{ExprContext, ResolveTo};
use crate::sema::solana_accounts::BuiltinAccounts;
use crate::sema::symtable::Symtable;
use crate::sema::unused_variable::{assigned_variable, used_variable};
use crate::Target;
use num_bigint::BigInt;
use num_traits::FromPrimitive;
use solang_parser::diagnostics::{Diagnostic, Note};
use solang_parser::pt;
use solang_parser::pt::CodeLocation;
/// Resolve an member access expression
pub(super) fn member_access(
loc: &pt::Loc,
e: &pt::Expression,
id: &pt::Identifier,
context: &mut ExprContext,
ns: &mut Namespace,
symtable: &mut Symtable,
diagnostics: &mut Diagnostics,
resolve_to: ResolveTo,
) -> Result<Expression, ()> {
// is it a builtin special variable like "block.timestamp"
if let pt::Expression::Variable(namespace) = e {
if let Some((builtin, ty)) =
builtin::builtin_var(loc, Some(&namespace.name), &id.name, ns, diagnostics)
{
return Ok(Expression::Builtin {
loc: *loc,
tys: vec![ty],
kind: builtin,
args: vec![],
});
}
if builtin::builtin_namespace(&namespace.name) {
diagnostics.push(Diagnostic::error(
e.loc(),
format!("builtin '{}.{}' does not exist", namespace.name, id.name),
));
return Err(());
}
}
// is it an enum value
if let Some(expr) = enum_value(
loc,
e,
id,
context.file_no,
context.contract_no,
ns,
diagnostics,
)? {
return Ok(expr);
}
// is it an event selector
if let Some(expr) = event_selector(
loc,
e,
id,
context.file_no,
context.contract_no,
ns,
diagnostics,
)? {
return Ok(expr);
}
// is it a constant (unless basecontract is a local variable)
if let Some(expr) =
contract_constant(loc, e, id, ns, symtable, context, diagnostics, resolve_to)?
{
return Ok(expr);
}
// is it a basecontract.function.selector expression (unless basecontract is a local variable)
if let pt::Expression::Variable(namespace) = e {
if symtable.find(context, &namespace.name).is_none() {
if let Some(call_contract_no) = ns.resolve_contract(context.file_no, namespace) {
// find function with this name
let mut name_matches = 0;
let mut expr = Err(());
for function_no in ns.contracts[call_contract_no].all_functions.keys() {
let func = &ns.functions[*function_no];
if func.id.name != id.name || func.ty != pt::FunctionTy::Function {
continue;
}
name_matches += 1;
let mut id_path = ns.expr_to_identifier_path(e).unwrap();
id_path.identifiers.push(id.clone());
id_path.loc = *loc;
expr = Ok(Expression::InternalFunction {
loc: e.loc(),
id: id_path,
ty: function_type(func, false, resolve_to),
function_no: *function_no,
signature: None,
})
}
return match name_matches {
0 => {
diagnostics.push(Diagnostic::error(
e.loc(),
format!(
"contract '{}' does not have a member called '{}'",
ns.contracts[call_contract_no].id, id.name,
),
));
Err(())
}
1 => expr,
_ => {
diagnostics.push(Diagnostic::error(
e.loc(),
format!(
"function '{}' of contract '{}' is overloaded",
id.name, ns.contracts[call_contract_no].id,
),
));
Err(())
}
};
}
}
}
let expr = expression(e, context, ns, symtable, diagnostics, resolve_to)?;
if let Expression::TypeOperator { .. } = &expr {
return type_name_expr(loc, expr, id, context, ns, diagnostics);
}
let expr_ty = expr.ty();
if let Type::Struct(struct_ty) = expr_ty.deref_memory() {
if let Some((i, f)) = struct_ty
.definition(ns)
.fields
.iter()
.enumerate()
.find(|f| id.name == f.1.name_as_str())
{
return if context.lvalue && f.readonly {
diagnostics.push(Diagnostic::error(
id.loc,
format!(
"struct '{}' field '{}' is readonly",
struct_ty.definition(ns),
id.name
),
));
Err(())
} else if f.readonly {
// readonly fields return the value, not a reference
Ok(Expression::StructMember {
loc: id.loc,
ty: f.ty.clone(),
expr: Box::new(expr),
field: i,
})
} else {
Ok(Expression::StructMember {
loc: id.loc,
ty: Type::Ref(Box::new(f.ty.clone())),
expr: Box::new(expr),
field: i,
})
};
} else {
diagnostics.push(Diagnostic::error(
id.loc,
format!(
"struct '{}' does not have a field called '{}'",
struct_ty.definition(ns),
id.name
),
));
return Err(());
}
}
// Dereference if need to
let (expr, expr_ty) = if let Type::Ref(ty) = &expr_ty {
(
Expression::Load {
loc: *loc,
ty: *ty.clone(),
expr: Box::new(expr),
},
ty.as_ref().clone(),
)
} else {
(expr, expr_ty)
};
match expr_ty {
Type::Bytes(n) => {
if id.name == "length" {
//We should not eliminate an array from the code when 'length' is called
//So the variable is also assigned a value to be read from 'length'
assigned_variable(ns, &expr, symtable);
used_variable(ns, &expr, symtable);
return Ok(Expression::NumberLiteral {
loc: *loc,
ty: Type::Uint(8),
value: BigInt::from_u8(n).unwrap(),
});
}
}
Type::Array(elem_ty, dim) => {
if id.name == "length" {
return match dim.last().unwrap() {
ArrayLength::Dynamic => Ok(Expression::Builtin {
loc: *loc,
tys: vec![Type::Uint(32)],
kind: Builtin::ArrayLength,
args: vec![expr],
}),
ArrayLength::Fixed(d) => {
//We should not eliminate an array from the code when 'length' is called
//So the variable is also assigned a value to be read from 'length'
assigned_variable(ns, &expr, symtable);
used_variable(ns, &expr, symtable);
bigint_to_expression(
loc,
d,
ns,
diagnostics,
ResolveTo::Type(&Type::Uint(32)),
None,
)
}
ArrayLength::AnyFixed => unreachable!(),
};
} else if matches!(*elem_ty, Type::Struct(StructType::AccountInfo))
&& context.function_no.is_some()
&& ns.target == Target::Solana
{
return if ns.functions[context.function_no.unwrap()]
.solana_accounts
.borrow()
.contains_key(&id.name)
|| id.name == BuiltinAccounts::DataAccount
{
Ok(Expression::NamedMember {
loc: *loc,
ty: Type::Ref(Box::new(Type::Struct(StructType::AccountInfo))),
array: Box::new(expr),
name: id.name.clone(),
})
} else {
diagnostics.push(Diagnostic::error(
id.loc,
"unrecognized account".to_string(),
));
Err(())
};
}
}
Type::String | Type::DynamicBytes | Type::Slice(_) => {
if id.name == "length" {
return Ok(Expression::Builtin {
loc: *loc,
tys: vec![Type::Uint(32)],
kind: Builtin::ArrayLength,
args: vec![expr],
});
}
}
Type::StorageRef(immutable, r) => match *r {
Type::Struct(str_ty) => {
return if let Some((field_no, field)) = str_ty
.definition(ns)
.fields
.iter()
.enumerate()
.find(|(_, field)| id.name == field.name_as_str())
{
Ok(Expression::StructMember {
loc: id.loc,
ty: Type::StorageRef(immutable, Box::new(field.ty.clone())),
expr: Box::new(expr),
field: field_no,
})
} else {
diagnostics.push(Diagnostic::error(
id.loc,
format!(
"struct '{}' does not have a field called '{}'",
str_ty.definition(ns).id,
id.name
),
));
Err(())
}
}
Type::Array(_, dim) => {
if id.name == "length" {
let elem_ty = expr.ty().storage_array_elem().deref_into();
if let Some(ArrayLength::Fixed(dim)) = dim.last() {
// sparse array could be large than ns.storage_type() on Solana
if dim.bits() > ns.storage_type().bits(ns) as u64 {
return Ok(Expression::StorageArrayLength {
loc: id.loc,
ty: Type::Uint(256),
array: Box::new(expr),
elem_ty,
});
}
}
return Ok(Expression::StorageArrayLength {
loc: id.loc,
ty: ns.storage_type(),
array: Box::new(expr),
elem_ty,
});
}
}
Type::Bytes(_) | Type::DynamicBytes | Type::String => {
if id.name == "length" {
let elem_ty = expr.ty().storage_array_elem().deref_into();
return Ok(Expression::StorageArrayLength {
loc: id.loc,
ty: Type::Uint(32),
array: Box::new(expr),
elem_ty,
});
}
}
_ => {}
},
Type::Address(_) if id.name == "balance" => {
if ns.target.is_polkadot() {
let mut is_this = false;
if let Expression::Cast { expr: this, .. } = &expr {
if let Expression::Builtin {
kind: Builtin::GetAddress,
..
} = this.as_ref()
{
is_this = true;
}
}
if !is_this {
diagnostics.push(Diagnostic::error(
expr.loc(),
"polkadot can only retrieve balance of 'this', like 'address(this).balance'"
.to_string(),
));
return Err(());
}
} else if ns.target == Target::Solana {
diagnostics.push(Diagnostic::error(
expr.loc(),
"balance is not available on Solana. Use \
tx.accounts.account_name.lamports to fetch the balance."
.to_string(),
));
return Err(());
}
used_variable(ns, &expr, symtable);
return Ok(Expression::Builtin {
loc: *loc,
tys: vec![Type::Value],
kind: Builtin::Balance,
args: vec![expr],
});
}
Type::Address(_) if id.name == "code" => {
if ns.target != Target::EVM {
diagnostics.push(Diagnostic::error(
expr.loc(),
format!("'address.code' is not supported on {}", ns.target),
));
return Err(());
}
used_variable(ns, &expr, symtable);
return Ok(Expression::Builtin {
loc: *loc,
tys: vec![Type::DynamicBytes],
kind: Builtin::ContractCode,
args: vec![expr],
});
}
Type::Contract(ref_contract_no) => {
let mut name_matches = 0;
let mut ext_expr = Err(());
for function_no in ns.contracts[ref_contract_no].all_functions.keys() {
let func = &ns.functions[*function_no];
if func.id.name != id.name
|| func.ty != pt::FunctionTy::Function
|| !func.is_public()
{
continue;
}
let ty = Type::ExternalFunction {
params: func.params.iter().map(|p| p.ty.clone()).collect(),
mutability: func.mutability.clone(),
returns: func.returns.iter().map(|p| p.ty.clone()).collect(),
};
name_matches += 1;
ext_expr = Ok(Expression::ExternalFunction {
loc: id.loc,
ty,
address: Box::new(expr.clone()),
function_no: *function_no,
});
}
return match name_matches {
0 => {
diagnostics.push(Diagnostic::error(
id.loc,
format!(
"{} '{}' has no public function '{}'",
ns.contracts[ref_contract_no].ty,
ns.contracts[ref_contract_no].id,
id.name
),
));
Err(())
}
1 => ext_expr,
_ => {
diagnostics.push(Diagnostic::error(
id.loc,
format!(
"function '{}' of {} '{}' is overloaded",
id.name,
ns.contracts[ref_contract_no].ty,
ns.contracts[ref_contract_no].id
),
));
Err(())
}
};
}
Type::ExternalFunction { .. } => {
if id.name == "address" {
used_variable(ns, &expr, symtable);
return Ok(Expression::Builtin {
loc: e.loc(),
tys: vec![Type::Address(false)],
kind: Builtin::ExternalFunctionAddress,
args: vec![expr],
});
}
if id.name == "selector" {
used_variable(ns, &expr, symtable);
return Ok(Expression::Builtin {
loc: e.loc(),
tys: vec![Type::FunctionSelector],
kind: Builtin::FunctionSelector,
args: vec![expr],
});
}
}
Type::InternalFunction { .. } => {
if let Expression::InternalFunction { .. } = expr {
if id.name == "selector" {
used_variable(ns, &expr, symtable);
return Ok(Expression::Builtin {
loc: e.loc(),
tys: vec![Type::FunctionSelector],
kind: Builtin::FunctionSelector,
args: vec![expr],
});
}
}
}
_ => (),
}
diagnostics.push(Diagnostic::error(*loc, format!("'{}' not found", id.name)));
Err(())
}
fn contract_constant(
loc: &pt::Loc,
e: &pt::Expression,
id: &pt::Identifier,
ns: &mut Namespace,
symtable: &mut Symtable,
context: &mut ExprContext,
diagnostics: &mut Diagnostics,
resolve_to: ResolveTo,
) -> Result<Option<Expression>, ()> {
let namespace = match e {
pt::Expression::Variable(namespace) => namespace,
_ => return Ok(None),
};
if symtable.find(context, &namespace.name).is_some() {
return Ok(None);
}
if let Some(contract_no) = ns.resolve_contract(context.file_no, namespace) {
if let Some((var_no, var)) = ns.contracts[contract_no]
.variables
.iter_mut()
.enumerate()
.find(|(_, variable)| variable.name == id.name)
{
if !var.constant {
let resolve_function = if let ResolveTo::Type(ty) = resolve_to {
matches!(
ty,
Type::InternalFunction { .. } | Type::ExternalFunction { .. }
)
} else {
false
};
if resolve_function {
// requested function, fall through
return Ok(None);
} else {
diagnostics.push(Diagnostic::error(
*loc,
format!(
"need instance of contract '{}' to get variable value '{}'",
ns.contracts[contract_no].id,
ns.contracts[contract_no].variables[var_no].name,
),
));
return Err(());
}
}
var.read = true;
return Ok(Some(Expression::ConstantVariable {
loc: *loc,
ty: var.ty.clone(),
contract_no: Some(contract_no),
var_no,
}));
}
}
Ok(None)
}
/// Try to resolve expression as an enum value. An enum can be prefixed
/// with import symbols, contract namespace before the enum type
fn enum_value(
loc: &pt::Loc,
expr: &pt::Expression,
id: &pt::Identifier,
file_no: usize,
contract_no: Option<usize>,
ns: &Namespace,
diagnostics: &mut Diagnostics,
) -> Result<Option<Expression>, ()> {
let mut namespace = Vec::new();
let mut expr = expr;
// the first element of the path is the deepest in the parse tree,
// so walk down and add to a list
while let pt::Expression::MemberAccess(_, member, name) = expr {
namespace.push(name);
expr = member.as_ref();
}
if let pt::Expression::Variable(name) = expr {
namespace.push(name);
} else {
return Ok(None);
}
// The leading part of the namespace can be import variables
let mut file_no = file_no;
// last element in our namespace vector is first element
while let Some(name) = namespace.last().map(|f| f.name.clone()) {
if let Some(Symbol::Import(_, import_file_no)) =
ns.variable_symbols.get(&(file_no, None, name))
{
file_no = *import_file_no;
namespace.pop();
} else {
break;
}
}
if namespace.is_empty() {
return Ok(None);
}
let mut contract_no = contract_no;
if let Some(no) = ns.resolve_contract(file_no, namespace.last().unwrap()) {
contract_no = Some(no);
namespace.pop();
}
if namespace.len() != 1 {
return Ok(None);
}
if let Some(e) = ns.resolve_enum(file_no, contract_no, namespace[0]) {
match ns.enums[e].values.get_full(&id.name) {
Some((val, _, _)) => Ok(Some(Expression::NumberLiteral {
loc: *loc,
ty: Type::Enum(e),
value: BigInt::from_usize(val).unwrap(),
})),
None => {
diagnostics.push(Diagnostic::error(
id.loc,
format!("enum {} does not have value {}", ns.enums[e], id.name),
));
Err(())
}
}
} else {
Ok(None)
}
}
fn event_selector(
loc: &pt::Loc,
expr: &pt::Expression,
id: &pt::Identifier,
file_no: usize,
contract_no: Option<usize>,
ns: &mut Namespace,
diagnostics: &mut Diagnostics,
) -> Result<Option<Expression>, ()> {
if id.name != "selector" {
return Ok(None);
}
if let Ok(events) = ns.resolve_event(file_no, contract_no, expr, &mut Diagnostics::default()) {
if events.len() == 1 {
let event_no = events[0];
if ns.events[event_no].anonymous {
diagnostics.push(Diagnostic::error(
*loc,
"anonymous event has no selector".into(),
));
Err(())
} else {
Ok(Some(Expression::EventSelector {
loc: *loc,
event_no,
ty: if ns.target == Target::Solana {
Type::Bytes(8)
} else {
Type::Bytes(32)
},
}))
}
} else {
let notes = events
.into_iter()
.map(|ev_no| {
let ev = &ns.events[ev_no];
Note {
loc: ev.id.loc,
message: format!("possible definition of '{}'", ev.id),
}
})
.collect();
diagnostics.push(Diagnostic::error_with_notes(
*loc,
"multiple definitions of event".into(),
notes,
));
Err(())
}
} else {
Ok(None)
}
}
/// Resolve type(x).foo
fn type_name_expr(
loc: &pt::Loc,
expr: Expression,
field: &pt::Identifier,
context: &mut ExprContext,
ns: &mut Namespace,
diagnostics: &mut Diagnostics,
) -> Result<Expression, ()> {
let Expression::TypeOperator { ty, .. } = &expr else {
unreachable!();
};
match field.name.as_str() {
"min" | "max" if matches!(ty, Type::Uint(_) | Type::Int(_) | Type::Enum(..)) => {
let ty = if matches!(ty, Type::Enum(..)) {
Type::Uint(8)
} else {
ty.clone()
};
let kind = if field.name == "min" {
Builtin::TypeMin
} else {
Builtin::TypeMax
};
return Ok(Expression::Builtin {
loc: *loc,
tys: vec![ty],
kind,
args: vec![expr],
});
}
"name" if matches!(ty, Type::Contract(..)) => {
return Ok(Expression::Builtin {
loc: *loc,
tys: vec![Type::String],
kind: Builtin::TypeName,
args: vec![expr],
})
}
"interfaceId" => {
if let Type::Contract(no) = ty {
let contract = &ns.contracts[*no];
return if !contract.is_interface() {
diagnostics.push(Diagnostic::error(
*loc,
format!(
"type(…).interfaceId is permitted on interface, not {} {}",
contract.ty, contract.id
),
));
Err(())
} else {
Ok(Expression::Builtin {
loc: *loc,
tys: vec![Type::FunctionSelector],
kind: Builtin::TypeInterfaceId,
args: vec![expr],
})
};
}
}
"creationCode" | "runtimeCode" => {
if let Type::Contract(no) = ty {
if !ns.contracts[*no].instantiable {
diagnostics.push(Diagnostic::error(
*loc,
format!(
"cannot construct '{}' of type '{}'",
ns.contracts[*no].id, ns.contracts[*no].ty
),
));
return Err(());
}
// This is not always in a function: e.g. contract constant:
// contract C {
// bytes constant code = type(D).runtimeCode;
// }
if let Some(function_no) = context.function_no {
ns.functions[function_no].creates.push((*loc, *no));
}
if let Some(contract_no) = context.contract_no {
// check for circular references
if *no == contract_no {
diagnostics.push(Diagnostic::error(
*loc,
format!(
"cannot construct current contract '{}'",
ns.contracts[*no].id
),
));
return Err(());
}
if circular_reference(*no, contract_no, ns) {
diagnostics.push(Diagnostic::error(
*loc,
format!(
"circular reference creating contract code for '{}'",
ns.contracts[*no].id
),
));
return Err(());
}
if !ns.contracts[contract_no].creates.contains(no) {
ns.contracts[contract_no].creates.push(*no);
}
}
let kind = if field.name == "runtimeCode" {
if ns.target == Target::EVM {
let notes: Vec<_> = ns.contracts[*no]
.variables
.iter()
.filter_map(|v| {
if v.immutable {
Some(Note {
loc: v.loc,
message: format!("immutable variable {}", v.name),
})
} else {
None
}
})
.collect();
if !notes.is_empty() {
diagnostics.push(Diagnostic::error_with_notes(
*loc,
format!(
"runtimeCode is not available for contract '{}' with immutuables",
ns.contracts[*no].id
),
notes,
));
}
}
Builtin::TypeRuntimeCode
} else {
Builtin::TypeCreatorCode
};
return Ok(Expression::Builtin {
loc: *loc,
tys: vec![Type::DynamicBytes],
kind,
args: vec![expr],
});
}
}
_ => (),
};
diagnostics.push(Diagnostic::error(
*loc,
format!(
"type '{}' does not have type function {}",
ty.to_string(ns),
field.name
),
));
Err(())
}