1
2
3
4
5
6
7 package types2
8
9 import (
10 "cmd/compile/internal/syntax"
11 . "internal/types/errors"
12 "strings"
13 )
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *syntax.IndexExpr, infer bool) ([]Type, []syntax.Expr) {
35 assert(T != nil || inst != nil)
36
37 var instErrPos poser
38 if inst != nil {
39 instErrPos = inst.Pos()
40 x.expr = inst
41 } else {
42 instErrPos = pos
43 }
44 versionErr := !check.verifyVersionf(instErrPos, go1_18, "function instantiation")
45
46
47 var targs []Type
48 var xlist []syntax.Expr
49 if inst != nil {
50 xlist = syntax.UnpackListExpr(inst.Index)
51 targs = check.typeList(xlist)
52 if targs == nil {
53 x.mode = invalid
54 return nil, nil
55 }
56 assert(len(targs) == len(xlist))
57 }
58
59
60
61
62 sig := x.typ.(*Signature)
63 got, want := len(targs), sig.TypeParams().Len()
64 if got > want {
65
66 check.errorf(xlist[got-1], WrongTypeArgCount, "got %d type arguments but want %d", got, want)
67 x.mode = invalid
68 return nil, nil
69 }
70
71 if got < want {
72 if !infer {
73 return targs, xlist
74 }
75
76
77
78
79
80
81
82
83
84
85
86 var args []*operand
87 var params []*Var
88 var reverse bool
89 if T != nil && sig.tparams != nil {
90 if !versionErr && !check.allowVersion(go1_21) {
91 if inst != nil {
92 check.versionErrorf(instErrPos, go1_21, "partially instantiated function in assignment")
93 } else {
94 check.versionErrorf(instErrPos, go1_21, "implicitly instantiated function in assignment")
95 }
96 }
97 gsig := NewSignatureType(nil, nil, nil, sig.params, sig.results, sig.variadic)
98 params = []*Var{NewVar(x.Pos(), check.pkg, "", gsig)}
99
100
101
102 expr := syntax.NewName(x.Pos(), T.desc)
103 args = []*operand{{mode: value, expr: expr, typ: T.sig}}
104 reverse = true
105 }
106
107
108
109 tparams, params2 := check.renameTParams(pos, sig.TypeParams().list(), NewTuple(params...))
110
111 err := check.newError(CannotInferTypeArgs)
112 targs = check.infer(pos, tparams, targs, params2.(*Tuple), args, reverse, err)
113 if targs == nil {
114 if !err.empty() {
115 err.report()
116 }
117 x.mode = invalid
118 return nil, nil
119 }
120 got = len(targs)
121 }
122 assert(got == want)
123
124
125 sig = check.instantiateSignature(x.Pos(), x.expr, sig, targs, xlist)
126
127 x.typ = sig
128 x.mode = value
129 return nil, nil
130 }
131
132 func (check *Checker) instantiateSignature(pos syntax.Pos, expr syntax.Expr, typ *Signature, targs []Type, xlist []syntax.Expr) (res *Signature) {
133 assert(check != nil)
134 assert(len(targs) == typ.TypeParams().Len())
135
136 if check.conf.Trace {
137 check.trace(pos, "-- instantiating signature %s with %s", typ, targs)
138 check.indent++
139 defer func() {
140 check.indent--
141 check.trace(pos, "=> %s (under = %s)", res, res.Underlying())
142 }()
143 }
144
145
146
147
148 inst := check.instance(pos, typ, targs, nil, check.context()).(*Signature)
149 assert(inst.TypeParams().Len() == 0)
150 check.recordInstance(expr, targs, inst)
151 assert(len(xlist) <= len(targs))
152
153
154 check.later(func() {
155 tparams := typ.TypeParams().list()
156
157 if i, err := check.verify(pos, tparams, targs, check.context()); err != nil {
158
159 pos := pos
160 if i < len(xlist) {
161 pos = syntax.StartPos(xlist[i])
162 }
163 check.softErrorf(pos, InvalidTypeArg, "%s", err)
164 } else {
165 check.mono.recordInstance(check.pkg, pos, tparams, targs, xlist)
166 }
167 }).describef(pos, "verify instantiation")
168
169 return inst
170 }
171
172 func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
173 var inst *syntax.IndexExpr
174 if iexpr, _ := call.Fun.(*syntax.IndexExpr); iexpr != nil {
175 if check.indexExpr(x, iexpr) {
176
177
178
179 assert(x.mode == value)
180 inst = iexpr
181 }
182 x.expr = iexpr
183 check.record(x)
184 } else {
185 check.exprOrType(x, call.Fun, true)
186 }
187
188
189 switch x.mode {
190 case invalid:
191 check.use(call.ArgList...)
192 x.expr = call
193 return statement
194
195 case typexpr:
196
197 check.nonGeneric(nil, x)
198 if x.mode == invalid {
199 return conversion
200 }
201 T := x.typ
202 x.mode = invalid
203 switch n := len(call.ArgList); n {
204 case 0:
205 check.errorf(call, WrongArgCount, "missing argument in conversion to %s", T)
206 case 1:
207 check.expr(nil, x, call.ArgList[0])
208 if x.mode != invalid {
209 if t, _ := under(T).(*Interface); t != nil && !isTypeParam(T) {
210 if !t.IsMethodSet() {
211 check.errorf(call, MisplacedConstraintIface, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T)
212 break
213 }
214 }
215 if hasDots(call) {
216 check.errorf(call.ArgList[0], BadDotDotDotSyntax, "invalid use of ... in conversion to %s", T)
217 break
218 }
219 check.conversion(x, T)
220 }
221 default:
222 check.use(call.ArgList...)
223 check.errorf(call.ArgList[n-1], WrongArgCount, "too many arguments in conversion to %s", T)
224 }
225 x.expr = call
226 return conversion
227
228 case builtin:
229
230 id := x.id
231 if !check.builtin(x, call, id) {
232 x.mode = invalid
233 }
234 x.expr = call
235
236 if x.mode != invalid && x.mode != constant_ {
237 check.hasCallOrRecv = true
238 }
239 return predeclaredFuncs[id].kind
240 }
241
242
243
244 cgocall := x.mode == cgofunc
245
246
247 sig, _ := coreType(x.typ).(*Signature)
248 if sig == nil {
249 check.errorf(x, InvalidCall, invalidOp+"cannot call non-function %s", x)
250 x.mode = invalid
251 x.expr = call
252 return statement
253 }
254
255
256 wasGeneric := sig.TypeParams().Len() > 0
257
258
259 var xlist []syntax.Expr
260 var targs []Type
261 if inst != nil {
262 xlist = syntax.UnpackListExpr(inst.Index)
263 targs = check.typeList(xlist)
264 if targs == nil {
265 check.use(call.ArgList...)
266 x.mode = invalid
267 x.expr = call
268 return statement
269 }
270 assert(len(targs) == len(xlist))
271
272
273 got, want := len(targs), sig.TypeParams().Len()
274 if got > want {
275 check.errorf(xlist[want], WrongTypeArgCount, "got %d type arguments but want %d", got, want)
276 check.use(call.ArgList...)
277 x.mode = invalid
278 x.expr = call
279 return statement
280 }
281
282
283
284
285
286
287 if got == want && want > 0 {
288 check.verifyVersionf(inst, go1_18, "function instantiation")
289 sig = check.instantiateSignature(inst.Pos(), inst, sig, targs, xlist)
290
291
292 targs = nil
293 xlist = nil
294 }
295 }
296
297
298 args, atargs, atxlist := check.genericExprList(call.ArgList)
299 sig = check.arguments(call, sig, targs, xlist, args, atargs, atxlist)
300
301 if wasGeneric && sig.TypeParams().Len() == 0 {
302
303 check.recordTypeAndValue(call.Fun, value, sig, nil)
304 }
305
306
307 switch sig.results.Len() {
308 case 0:
309 x.mode = novalue
310 case 1:
311 if cgocall {
312 x.mode = commaerr
313 } else {
314 x.mode = value
315 }
316 x.typ = sig.results.vars[0].typ
317 default:
318 x.mode = value
319 x.typ = sig.results
320 }
321 x.expr = call
322 check.hasCallOrRecv = true
323
324
325
326 if x.mode == value && sig.TypeParams().Len() > 0 && isParameterized(sig.TypeParams().list(), x.typ) {
327 x.mode = invalid
328 }
329
330 return statement
331 }
332
333
334
335 func (check *Checker) exprList(elist []syntax.Expr) (xlist []*operand) {
336 if n := len(elist); n == 1 {
337 xlist, _ = check.multiExpr(elist[0], false)
338 } else if n > 1 {
339
340 xlist = make([]*operand, n)
341 for i, e := range elist {
342 var x operand
343 check.expr(nil, &x, e)
344 xlist[i] = &x
345 }
346 }
347 return
348 }
349
350
351
352
353
354
355
356
357 func (check *Checker) genericExprList(elist []syntax.Expr) (resList []*operand, targsList [][]Type, xlistList [][]syntax.Expr) {
358 if debug {
359 defer func() {
360
361 assert(len(targsList) == len(xlistList))
362
363 for i, x := range resList {
364 if i < len(targsList) {
365 if n := len(targsList[i]); n > 0 {
366
367 assert(n < x.typ.(*Signature).TypeParams().Len())
368 }
369 }
370 }
371 }()
372 }
373
374
375
376 infer := true
377 n := len(elist)
378 if n > 0 && check.allowVersion(go1_21) {
379 infer = false
380 }
381
382 if n == 1 {
383
384 e := elist[0]
385 var x operand
386 if inst, _ := e.(*syntax.IndexExpr); inst != nil && check.indexExpr(&x, inst) {
387
388 targs, xlist := check.funcInst(nil, x.Pos(), &x, inst, infer)
389 if targs != nil {
390
391 targsList = [][]Type{targs}
392 xlistList = [][]syntax.Expr{xlist}
393
394 x.expr = inst
395 } else {
396
397
398 check.record(&x)
399 }
400 resList = []*operand{&x}
401 } else {
402
403 check.rawExpr(nil, &x, e, nil, true)
404 check.exclude(&x, 1<<novalue|1<<builtin|1<<typexpr)
405 if t, ok := x.typ.(*Tuple); ok && x.mode != invalid {
406
407 resList = make([]*operand, t.Len())
408 for i, v := range t.vars {
409 resList[i] = &operand{mode: value, expr: e, typ: v.typ}
410 }
411 } else {
412
413 resList = []*operand{&x}
414 }
415 }
416 } else if n > 1 {
417
418 resList = make([]*operand, n)
419 targsList = make([][]Type, n)
420 xlistList = make([][]syntax.Expr, n)
421 for i, e := range elist {
422 var x operand
423 if inst, _ := e.(*syntax.IndexExpr); inst != nil && check.indexExpr(&x, inst) {
424
425 targs, xlist := check.funcInst(nil, x.Pos(), &x, inst, infer)
426 if targs != nil {
427
428 targsList[i] = targs
429 xlistList[i] = xlist
430
431 x.expr = inst
432 } else {
433
434
435 check.record(&x)
436 }
437 } else {
438
439 check.genericExpr(&x, e)
440 }
441 resList[i] = &x
442 }
443 }
444
445 return
446 }
447
448
449
450
451
452
453
454
455
456
457
458
459
460 func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []Type, xlist []syntax.Expr, args []*operand, atargs [][]Type, atxlist [][]syntax.Expr) (rsig *Signature) {
461 rsig = sig
462
463
464
465
466
467
468
469
470
471
472 nargs := len(args)
473 npars := sig.params.Len()
474 ddd := hasDots(call)
475
476
477 sigParams := sig.params
478 adjusted := false
479 if sig.variadic {
480 if ddd {
481
482 if len(call.ArgList) == 1 && nargs > 1 {
483
484
485 check.errorf(call, InvalidDotDotDot, "cannot use ... with %d-valued %s", nargs, call.ArgList[0])
486 return
487 }
488 } else {
489
490 if nargs >= npars-1 {
491
492
493
494 vars := make([]*Var, npars-1)
495 copy(vars, sig.params.vars)
496 last := sig.params.vars[npars-1]
497 typ := last.typ.(*Slice).elem
498 for len(vars) < nargs {
499 vars = append(vars, NewParam(last.pos, last.pkg, last.name, typ))
500 }
501 sigParams = NewTuple(vars...)
502 adjusted = true
503 npars = nargs
504 } else {
505
506 npars--
507 }
508 }
509 } else {
510 if ddd {
511
512
513 check.errorf(call, NonVariadicDotDotDot, "cannot use ... in call to non-variadic %s", call.Fun)
514 return
515 }
516
517 }
518
519
520 if nargs != npars {
521 var at poser = call
522 qualifier := "not enough"
523 if nargs > npars {
524 at = args[npars].expr
525 qualifier = "too many"
526 } else if nargs > 0 {
527 at = args[nargs-1].expr
528 }
529
530 var params []*Var
531 if sig.params != nil {
532 params = sig.params.vars
533 }
534 err := check.newError(WrongArgCount)
535 err.addf(at, "%s arguments in call to %s", qualifier, call.Fun)
536 err.addf(nopos, "have %s", check.typesSummary(operandTypes(args), false, ddd))
537 err.addf(nopos, "want %s", check.typesSummary(varTypes(params), sig.variadic, false))
538 err.report()
539 return
540 }
541
542
543 var tparams []*TypeParam
544
545
546 n := sig.TypeParams().Len()
547 if n > 0 {
548 if !check.allowVersion(go1_18) {
549 if iexpr, _ := call.Fun.(*syntax.IndexExpr); iexpr != nil {
550 check.versionErrorf(iexpr, go1_18, "function instantiation")
551 } else {
552 check.versionErrorf(call, go1_18, "implicit function instantiation")
553 }
554 }
555
556 var tmp Type
557 tparams, tmp = check.renameTParams(call.Pos(), sig.TypeParams().list(), sigParams)
558 sigParams = tmp.(*Tuple)
559
560 for len(targs) < len(tparams) {
561 targs = append(targs, nil)
562 }
563 }
564 assert(len(tparams) == len(targs))
565
566
567 var genericArgs []int
568 if enableReverseTypeInference {
569 for i, arg := range args {
570
571 if asig, _ := arg.typ.(*Signature); asig != nil && asig.TypeParams().Len() > 0 {
572
573
574
575
576
577
578 asig = clone(asig)
579
580
581
582
583 atparams, tmp := check.renameTParams(call.Pos(), asig.TypeParams().list(), asig)
584 asig = tmp.(*Signature)
585 asig.tparams = &TypeParamList{atparams}
586 arg.typ = asig
587 tparams = append(tparams, atparams...)
588
589 if i < len(atargs) {
590 targs = append(targs, atargs[i]...)
591 }
592
593 for len(targs) < len(tparams) {
594 targs = append(targs, nil)
595 }
596 genericArgs = append(genericArgs, i)
597 }
598 }
599 }
600 assert(len(tparams) == len(targs))
601
602
603 _ = len(genericArgs) > 0 && check.verifyVersionf(args[genericArgs[0]], go1_21, "implicitly instantiated function as argument")
604
605
606
607
608
609
610 if len(tparams) > 0 {
611 err := check.newError(CannotInferTypeArgs)
612 targs = check.infer(call.Pos(), tparams, targs, sigParams, args, false, err)
613 if targs == nil {
614
615
616
617
618 if !err.empty() {
619 check.errorf(err.pos(), CannotInferTypeArgs, "in call to %s, %s", call.Fun, err.msg())
620 }
621 return
622 }
623
624
625 if n > 0 {
626 rsig = check.instantiateSignature(call.Pos(), call.Fun, sig, targs[:n], xlist)
627
628
629
630 if adjusted {
631 sigParams = check.subst(call.Pos(), sigParams, makeSubstMap(tparams[:n], targs[:n]), nil, check.context()).(*Tuple)
632 } else {
633 sigParams = rsig.params
634 }
635 }
636
637
638 j := n
639 for _, i := range genericArgs {
640 arg := args[i]
641 asig := arg.typ.(*Signature)
642 k := j + asig.TypeParams().Len()
643
644 arg.typ = check.instantiateSignature(call.Pos(), arg.expr, asig, targs[j:k], nil)
645 check.record(arg)
646 j = k
647 }
648 }
649
650
651 if len(args) > 0 {
652 context := check.sprintf("argument to %s", call.Fun)
653 for i, a := range args {
654 check.assignment(a, sigParams.vars[i].typ, context)
655 }
656 }
657
658 return
659 }
660
661 var cgoPrefixes = [...]string{
662 "_Ciconst_",
663 "_Cfconst_",
664 "_Csconst_",
665 "_Ctype_",
666 "_Cvar_",
667 "_Cfpvar_fp_",
668 "_Cfunc_",
669 "_Cmacro_",
670 }
671
672 func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, def *TypeName, wantType bool) {
673
674 var (
675 obj Object
676 index []int
677 indirect bool
678 )
679
680 sel := e.Sel.Value
681
682
683
684
685 if ident, ok := e.X.(*syntax.Name); ok {
686 obj := check.lookup(ident.Value)
687 if pname, _ := obj.(*PkgName); pname != nil {
688 assert(pname.pkg == check.pkg)
689 check.recordUse(ident, pname)
690 check.usedPkgNames[pname] = true
691 pkg := pname.imported
692
693 var exp Object
694 funcMode := value
695 if pkg.cgo {
696
697
698
699 if sel == "malloc" {
700 sel = "_CMalloc"
701 } else {
702 funcMode = cgofunc
703 }
704 for _, prefix := range cgoPrefixes {
705
706
707 exp = check.lookup(prefix + sel)
708 if exp != nil {
709 break
710 }
711 }
712 if exp == nil {
713 if isValidName(sel) {
714 check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s", syntax.Expr(e))
715 }
716 goto Error
717 }
718 check.objDecl(exp, nil)
719 } else {
720 exp = pkg.scope.Lookup(sel)
721 if exp == nil {
722 if !pkg.fake && isValidName(sel) {
723 check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s", syntax.Expr(e))
724 }
725 goto Error
726 }
727 if !exp.Exported() {
728 check.errorf(e.Sel, UnexportedName, "name %s not exported by package %s", sel, pkg.name)
729
730 }
731 }
732 check.recordUse(e.Sel, exp)
733
734
735
736 switch exp := exp.(type) {
737 case *Const:
738 assert(exp.Val() != nil)
739 x.mode = constant_
740 x.typ = exp.typ
741 x.val = exp.val
742 case *TypeName:
743 x.mode = typexpr
744 x.typ = exp.typ
745 case *Var:
746 x.mode = variable
747 x.typ = exp.typ
748 if pkg.cgo && strings.HasPrefix(exp.name, "_Cvar_") {
749 x.typ = x.typ.(*Pointer).base
750 }
751 case *Func:
752 x.mode = funcMode
753 x.typ = exp.typ
754 if pkg.cgo && strings.HasPrefix(exp.name, "_Cmacro_") {
755 x.mode = value
756 x.typ = x.typ.(*Signature).results.vars[0].typ
757 }
758 case *Builtin:
759 x.mode = builtin
760 x.typ = exp.typ
761 x.id = exp.id
762 default:
763 check.dump("%v: unexpected object %v", atPos(e.Sel), exp)
764 panic("unreachable")
765 }
766 x.expr = e
767 return
768 }
769 }
770
771 check.exprOrType(x, e.X, false)
772 switch x.mode {
773 case typexpr:
774
775 if def != nil && def.typ == x.typ {
776 check.cycleError([]Object{def}, 0)
777 goto Error
778 }
779 case builtin:
780 check.errorf(e.Pos(), UncalledBuiltin, "invalid use of %s in selector expression", x)
781 goto Error
782 case invalid:
783 goto Error
784 }
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800 if wantType {
801 check.errorf(e.Sel, NotAType, "%s is not a type", syntax.Expr(e))
802 goto Error
803 }
804
805 obj, index, indirect = lookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel, false)
806 if obj == nil {
807
808 if !isValid(under(x.typ)) {
809 goto Error
810 }
811
812 if index != nil {
813
814 check.errorf(e.Sel, AmbiguousSelector, "ambiguous selector %s.%s", x.expr, sel)
815 goto Error
816 }
817
818 if indirect {
819 if x.mode == typexpr {
820 check.errorf(e.Sel, InvalidMethodExpr, "invalid method expression %s.%s (needs pointer receiver (*%s).%s)", x.typ, sel, x.typ, sel)
821 } else {
822 check.errorf(e.Sel, InvalidMethodExpr, "cannot call pointer method %s on %s", sel, x.typ)
823 }
824 goto Error
825 }
826
827 var why string
828 if isInterfacePtr(x.typ) {
829 why = check.interfacePtrError(x.typ)
830 } else {
831 alt, _, _ := lookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel, true)
832 why = check.lookupError(x.typ, sel, alt, false)
833 }
834 check.errorf(e.Sel, MissingFieldOrMethod, "%s.%s undefined (%s)", x.expr, sel, why)
835 goto Error
836 }
837
838
839 if m, _ := obj.(*Func); m != nil {
840 check.objDecl(m, nil)
841 }
842
843 if x.mode == typexpr {
844
845 m, _ := obj.(*Func)
846 if m == nil {
847 check.errorf(e.Sel, MissingFieldOrMethod, "%s.%s undefined (type %s has no method %s)", x.expr, sel, x.typ, sel)
848 goto Error
849 }
850
851 check.recordSelection(e, MethodExpr, x.typ, m, index, indirect)
852
853 sig := m.typ.(*Signature)
854 if sig.recv == nil {
855 check.error(e, InvalidDeclCycle, "illegal cycle in method declaration")
856 goto Error
857 }
858
859
860
861 var params []*Var
862 if sig.params != nil {
863 params = sig.params.vars
864 }
865
866
867
868
869
870
871 name := ""
872 if len(params) > 0 && params[0].name != "" {
873
874 name = sig.recv.name
875 if name == "" {
876 name = "_"
877 }
878 }
879 params = append([]*Var{NewVar(sig.recv.pos, sig.recv.pkg, name, x.typ)}, params...)
880 x.mode = value
881 x.typ = &Signature{
882 tparams: sig.tparams,
883 params: NewTuple(params...),
884 results: sig.results,
885 variadic: sig.variadic,
886 }
887
888 check.addDeclDep(m)
889
890 } else {
891
892 switch obj := obj.(type) {
893 case *Var:
894 check.recordSelection(e, FieldVal, x.typ, obj, index, indirect)
895 if x.mode == variable || indirect {
896 x.mode = variable
897 } else {
898 x.mode = value
899 }
900 x.typ = obj.typ
901
902 case *Func:
903
904
905 check.recordSelection(e, MethodVal, x.typ, obj, index, indirect)
906
907 x.mode = value
908
909
910 sig := *obj.typ.(*Signature)
911 sig.recv = nil
912 x.typ = &sig
913
914 check.addDeclDep(obj)
915
916 default:
917 panic("unreachable")
918 }
919 }
920
921
922 x.expr = e
923 return
924
925 Error:
926 x.mode = invalid
927 x.expr = e
928 }
929
930
931
932
933
934
935 func (check *Checker) use(args ...syntax.Expr) bool { return check.useN(args, false) }
936
937
938
939
940 func (check *Checker) useLHS(args ...syntax.Expr) bool { return check.useN(args, true) }
941
942 func (check *Checker) useN(args []syntax.Expr, lhs bool) bool {
943 ok := true
944 for _, e := range args {
945 if !check.use1(e, lhs) {
946 ok = false
947 }
948 }
949 return ok
950 }
951
952 func (check *Checker) use1(e syntax.Expr, lhs bool) bool {
953 var x operand
954 x.mode = value
955 switch n := syntax.Unparen(e).(type) {
956 case nil:
957
958 case *syntax.Name:
959
960 if n.Value == "_" {
961 break
962 }
963
964
965
966 var v *Var
967 var v_used bool
968 if lhs {
969 if obj := check.lookup(n.Value); obj != nil {
970
971
972
973 if w, _ := obj.(*Var); w != nil && w.pkg == check.pkg {
974 v = w
975 v_used = check.usedVars[v]
976 }
977 }
978 }
979 check.exprOrType(&x, n, true)
980 if v != nil {
981 check.usedVars[v] = v_used
982 }
983 case *syntax.ListExpr:
984 return check.useN(n.ElemList, lhs)
985 default:
986 check.rawExpr(nil, &x, e, nil, true)
987 }
988 return x.mode != invalid
989 }
990
View as plain text