1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 "cmd/compile/internal/syntax"
14 func (err *error_) recordAltDecl(obj Object) {
15 if pos := obj.Pos(); pos.IsKnown() {
16 // We use "other" rather than "previous" here because
17 // the first declaration seen may not be textually
18 // earlier in the source.
19 err.errorf(pos, "other declaration of %s", obj.Name())
23 func (check *Checker) declare(scope *Scope, id *syntax.Name, obj Object, pos syntax.Pos) {
24 // spec: "The blank identifier, represented by the underscore
25 // character _, may be used in a declaration like any other
26 // identifier but the declaration does not introduce a new
28 if obj.Name() != "_" {
29 if alt := scope.Insert(obj); alt != nil {
31 err.code = _DuplicateDecl
32 err.errorf(obj, "%s redeclared in this block", obj.Name())
33 err.recordAltDecl(alt)
40 check.recordDef(id, obj)
44 // pathString returns a string of the form a->b-> ... ->g for a path [a, b, ... g].
45 func pathString(path []Object) string {
47 for i, p := range path {
56 // objDecl type-checks the declaration of obj in its respective (file) environment.
57 // For the meaning of def, see Checker.definedType, in typexpr.go.
58 func (check *Checker) objDecl(obj Object, def *Named) {
59 if check.conf.Trace && obj.Type() == nil {
60 if check.indent == 0 {
61 fmt.Println() // empty line between top-level objects for readability
63 check.trace(obj.Pos(), "-- checking %s (%s, objPath = %s)", obj, obj.color(), pathString(check.objPath))
67 check.trace(obj.Pos(), "=> %s (%s)", obj, obj.color())
71 // Checking the declaration of obj means inferring its type
72 // (and possibly its value, for constants).
73 // An object's type (and thus the object) may be in one of
74 // three states which are expressed by colors:
76 // - an object whose type is not yet known is painted white (initial color)
77 // - an object whose type is in the process of being inferred is painted grey
78 // - an object whose type is fully inferred is painted black
80 // During type inference, an object's color changes from white to grey
81 // to black (pre-declared objects are painted black from the start).
82 // A black object (i.e., its type) can only depend on (refer to) other black
83 // ones. White and grey objects may depend on white and black objects.
84 // A dependency on a grey object indicates a cycle which may or may not be
87 // When objects turn grey, they are pushed on the object path (a stack);
88 // they are popped again when they turn black. Thus, if a grey object (a
89 // cycle) is encountered, it is on the object path, and all the objects
90 // it depends on are the remaining objects on that path. Color encoding
91 // is such that the color value of a grey object indicates the index of
92 // that object in the object path.
94 // During type-checking, white objects may be assigned a type without
95 // traversing through objDecl; e.g., when initializing constants and
96 // variables. Update the colors of those objects here (rather than
97 // everywhere where we set the type) to satisfy the color invariants.
98 if obj.color() == white && obj.Type() != nil {
105 assert(obj.Type() == nil)
106 // All color values other than white and black are considered grey.
107 // Because black and white are < grey, all values >= grey are grey.
108 // Use those values to encode the object's index into the object path.
109 obj.setColor(grey + color(check.push(obj)))
111 check.pop().setColor(black)
115 assert(obj.Type() != nil)
119 // Color values other than white or black are considered grey.
123 // We have a (possibly invalid) cycle.
124 // In the existing code, this is marked by a non-nil type
125 // for the object except for constants and variables whose
126 // type may be non-nil (known), or nil if it depends on the
127 // not-yet known initialization value.
128 // In the former case, set the type to Typ[Invalid] because
129 // we have an initialization cycle. The cycle error will be
130 // reported later, when determining initialization order.
131 // TODO(gri) Report cycle here and simplify initialization
133 switch obj := obj.(type) {
135 if !check.validCycle(obj) || obj.typ == nil {
136 obj.typ = Typ[Invalid]
140 if !check.validCycle(obj) || obj.typ == nil {
141 obj.typ = Typ[Invalid]
145 if !check.validCycle(obj) {
147 // (without this, calling underlying()
148 // below may lead to an endless loop
149 // if we have a cycle for a defined
151 obj.typ = Typ[Invalid]
155 if !check.validCycle(obj) {
156 // Don't set obj.typ to Typ[Invalid] here
157 // because plenty of code type-asserts that
158 // functions have a *Signature type. Grey
159 // functions have their type set to an empty
160 // signature which makes it impossible to
161 // initialize a variable with the function.
167 assert(obj.Type() != nil)
171 d := check.objMap[obj]
173 check.dump("%v: %s should have been declared", obj.Pos(), obj)
177 // save/restore current environment and set up object environment
178 defer func(env environment) {
179 check.environment = env
181 check.environment = environment{
185 // Const and var declarations must not have initialization
186 // cycles. We track them by remembering the current declaration
187 // in check.decl. Initialization expressions depending on other
188 // consts, vars, or functions, add dependencies to the current
190 switch obj := obj.(type) {
192 check.decl = d // new package-level const decl
193 check.constDecl(obj, d.vtyp, d.init, d.inherited)
195 check.decl = d // new package-level var decl
196 check.varDecl(obj, d.lhs, d.vtyp, d.init)
198 // invalid recursive types are detected via path
199 check.typeDecl(obj, d.tdecl, def)
200 check.collectMethods(obj) // methods can only be added to top-level types
202 // functions may be recursive - no need to track dependencies
203 check.funcDecl(obj, d)
209 // validCycle reports whether the cycle starting with obj is valid and
210 // reports an error if it is not.
211 func (check *Checker) validCycle(obj Object) (valid bool) {
212 // The object map contains the package scope objects and the non-interface methods.
214 info := check.objMap[obj]
215 inObjMap := info != nil && (info.fdecl == nil || info.fdecl.Recv == nil) // exclude methods
216 isPkgObj := obj.Parent() == check.pkg.scope
217 if isPkgObj != inObjMap {
218 check.dump("%v: inconsistent object map for %s (isPkgObj = %v, inObjMap = %v)", obj.Pos(), obj, isPkgObj, inObjMap)
223 // Count cycle objects.
224 assert(obj.color() >= grey)
225 start := obj.color() - grey // index of obj in objPath
226 cycle := check.objPath[start:]
227 tparCycle := false // if set, the cycle is through a type parameter list
228 nval := 0 // number of (constant or variable) values in the cycle; valid if !generic
229 ndef := 0 // number of type definitions in the cycle; valid if !generic
231 for _, obj := range cycle {
232 switch obj := obj.(type) {
236 // If we reach a generic type that is part of a cycle
237 // and we are in a type parameter list, we have a cycle
238 // through a type parameter list, which is invalid.
239 if check.inTParamList && isGeneric(obj.typ) {
244 // Determine if the type name is an alias or not. For
245 // package-level objects, use the object map which
246 // provides syntactic information (which doesn't rely
247 // on the order in which the objects are set up). For
248 // local objects, we can rely on the order, so use
249 // the object's predicate.
250 // TODO(gri) It would be less fragile to always access
251 // the syntactic information. We should consider storing
252 // this information explicitly in the object.
254 if d := check.objMap[obj]; d != nil {
255 alias = d.tdecl.Alias // package-level object
257 alias = obj.IsAlias() // function local object
269 if check.conf.Trace {
270 check.trace(obj.Pos(), "## cycle detected: objPath = %s->%s (len = %d)", pathString(cycle), obj.Name(), len(cycle))
272 check.trace(obj.Pos(), "## cycle contains: generic type in a type parameter list")
274 check.trace(obj.Pos(), "## cycle contains: %d values, %d type definitions", nval, ndef)
278 check.trace(obj.Pos(), "=> cycle is valid")
280 check.trace(obj.Pos(), "=> error: cycle is invalid")
286 // A cycle involving only constants and variables is invalid but we
287 // ignore them here because they are reported via the initialization
289 if nval == len(cycle) {
293 // A cycle involving only types (and possibly functions) must have at least
294 // one type definition to be permitted: If there is no type definition, we
295 // have a sequence of alias type names which will expand ad infinitum.
296 if nval == 0 && ndef > 0 {
301 check.cycleError(cycle)
305 // cycleError reports a declaration cycle starting with
306 // the object in cycle that is "first" in the source.
307 func (check *Checker) cycleError(cycle []Object) {
308 // name returns the (possibly qualified) object name.
309 // This is needed because with generic types, cycles
310 // may refer to imported types. See issue #50788.
311 // TODO(gri) Thus functionality is used elsewhere. Factor it out.
312 name := func(obj Object) string {
314 writePackage(&buf, obj.Pkg(), check.qualifier)
315 buf.WriteString(obj.Name())
319 // TODO(gri) Should we start with the last (rather than the first) object in the cycle
320 // since that is the earliest point in the source where we start seeing the
321 // cycle? That would be more consistent with other error messages.
322 i := firstInSrc(cycle)
325 // If obj is a type alias, mark it as valid (not broken) in order to avoid follow-on errors.
326 tname, _ := obj.(*TypeName)
327 if tname != nil && tname.IsAlias() {
328 check.validAlias(tname, Typ[Invalid])
331 if tname != nil && check.conf.CompilerErrorMessages {
332 err.errorf(obj, "invalid recursive type %s", objName)
334 err.errorf(obj, "illegal cycle in declaration of %s", objName)
337 err.errorf(obj, "%s refers to", objName)
345 err.errorf(obj, "%s", objName)
349 // firstInSrc reports the index of the object with the "smallest"
350 // source position in path. path must not be empty.
351 func firstInSrc(path []Object) int {
352 fst, pos := 0, path[0].Pos()
353 for i, t := range path[1:] {
354 if t.Pos().Cmp(pos) < 0 {
355 fst, pos = i+1, t.Pos()
361 func (check *Checker) constDecl(obj *Const, typ, init syntax.Expr, inherited bool) {
362 assert(obj.typ == nil)
364 // use the correct value of iota and errpos
365 defer func(iota constant.Value, errpos syntax.Pos) {
367 check.errpos = errpos
368 }(check.iota, check.errpos)
372 // provide valid constant value under all circumstances
373 obj.val = constant.MakeUnknown()
375 // determine type, if any
379 // don't report an error if the type is an invalid C (defined) type
381 if under(t) != Typ[Invalid] {
382 check.errorf(typ, _InvalidConstType, "invalid constant type %s", t)
384 obj.typ = Typ[Invalid]
390 // check initialization
394 // The initialization expression is inherited from a previous
395 // constant declaration, and (error) positions refer to that
396 // expression and not the current constant declaration. Use
397 // the constant identifier position for any errors during
398 // init expression evaluation since that is all we have
399 // (see issues #42991, #42992).
400 check.errpos = obj.pos
404 check.initConst(obj, &x)
407 func (check *Checker) varDecl(obj *Var, lhs []*Var, typ, init syntax.Expr) {
408 assert(obj.typ == nil)
410 // If we have undefined variable types due to errors,
411 // mark variables as used to avoid follow-on errors.
412 // Matches compiler behavior.
414 if obj.typ == Typ[Invalid] {
417 for _, lhs := range lhs {
418 if lhs.typ == Typ[Invalid] {
424 // determine type, if any
426 obj.typ = check.varType(typ)
427 // We cannot spread the type to all lhs variables if there
428 // are more than one since that would mark them as checked
429 // (see Checker.objDecl) and the assignment of init exprs,
430 // if any, would not be checked.
432 // TODO(gri) If we have no init expr, we should distribute
433 // a given type otherwise we need to re-evalate the type
434 // expr for each lhs variable, leading to duplicate work.
437 // check initialization
440 // error reported before by arityMatch
441 obj.typ = Typ[Invalid]
446 if lhs == nil || len(lhs) == 1 {
447 assert(lhs == nil || lhs[0] == obj)
450 check.initVar(obj, &x, "variable declaration")
455 // obj must be one of lhs
457 for _, lhs := range lhs {
464 panic("inconsistent lhs")
468 // We have multiple variables on the lhs and one init expr.
469 // Make sure all variables have been given the same type if
470 // one was specified, otherwise they assume the type of the
471 // init expression values (was issue #15755).
473 for _, lhs := range lhs {
478 check.initVars(lhs, []syntax.Expr{init}, nil)
481 // isImportedConstraint reports whether typ is an imported type constraint.
482 func (check *Checker) isImportedConstraint(typ Type) bool {
483 named, _ := typ.(*Named)
484 if named == nil || named.obj.pkg == check.pkg || named.obj.pkg == nil {
487 u, _ := named.under().(*Interface)
488 return u != nil && !u.IsMethodSet()
491 func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named) {
492 assert(obj.typ == nil)
496 if t, _ := obj.typ.(*Named); t != nil { // type may be invalid
499 // If typ is local, an error was already reported where typ is specified/defined.
500 if check.isImportedConstraint(rhs) && !check.allowVersion(check.pkg, 1, 18) {
501 check.versionErrorf(tdecl.Type, "go1.18", "using type constraint %s", rhs)
503 }).describef(obj, "validType(%s)", obj.Name())
506 if alias && tdecl.TParamList != nil {
507 // The parser will ensure this but we may still get an invalid AST.
508 // Complain and continue as regular type definition.
509 check.error(tdecl, _BadDecl, "generic type cannot be alias")
515 if !check.allowVersion(check.pkg, 1, 9) {
516 check.versionErrorf(tdecl, "go1.9", "type aliases")
519 check.brokenAlias(obj)
520 rhs = check.typ(tdecl.Type)
521 check.validAlias(obj, rhs)
525 // type definition or generic type declaration
526 named := check.newNamed(obj, nil, nil)
527 def.setUnderlying(named)
529 if tdecl.TParamList != nil {
530 check.openScope(tdecl, "type parameters")
531 defer check.closeScope()
532 check.collectTypeParams(&named.tparams, tdecl.TParamList)
535 // determine underlying type of named
536 rhs = check.definedType(tdecl.Type, named)
540 // If the underlying type was not set while type-checking the right-hand
541 // side, it is invalid and an error should have been reported elsewhere.
542 if named.underlying == nil {
543 named.underlying = Typ[Invalid]
546 // Disallow a lone type parameter as the RHS of a type declaration (issue #45639).
547 // We don't need this restriction anymore if we make the underlying type of a type
548 // parameter its constraint interface: if the RHS is a lone type parameter, we will
549 // use its underlying type (like we do for any RHS in a type declaration), and its
550 // underlying type is an interface and the type declaration is well defined.
551 if isTypeParam(rhs) {
552 check.error(tdecl.Type, _MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration")
553 named.underlying = Typ[Invalid]
557 func (check *Checker) collectTypeParams(dst **TypeParamList, list []*syntax.Field) {
558 tparams := make([]*TypeParam, len(list))
560 // Declare type parameters up-front.
561 // The scope of type parameters starts at the beginning of the type parameter
562 // list (so we can have mutually recursive parameterized type bounds).
563 for i, f := range list {
564 tparams[i] = check.declareTypeParam(f.Name)
567 // Set the type parameters before collecting the type constraints because
568 // the parameterized type may be used by the constraints (issue #47887).
569 // Example: type T[P T[P]] interface{}
570 *dst = bindTParams(tparams)
572 // Signal to cycle detection that we are in a type parameter list.
573 // We can only be inside one type parameter list at any given time:
574 // function closures may appear inside a type parameter list but they
575 // cannot be generic, and their bodies are processed in delayed and
576 // sequential fashion. Note that with each new declaration, we save
577 // the existing environment and restore it when done; thus inTParamList
578 // is true exactly only when we are in a specific type parameter list.
579 assert(!check.inTParamList)
580 check.inTParamList = true
582 check.inTParamList = false
585 // Keep track of bounds for later validation.
587 for i, f := range list {
588 // Optimization: Re-use the previous type bound if it hasn't changed.
589 // This also preserves the grouped output of type parameter lists
590 // when printing type strings.
591 if i == 0 || f.Type != list[i-1].Type {
592 bound = check.bound(f.Type)
593 if isTypeParam(bound) {
594 // We may be able to allow this since it is now well-defined what
595 // the underlying type and thus type set of a type parameter is.
596 // But we may need some additional form of cycle detection within
597 // type parameter lists.
598 check.error(f.Type, _MisplacedTypeParam, "cannot use a type parameter as constraint")
602 tparams[i].bound = bound
606 func (check *Checker) bound(x syntax.Expr) Type {
607 // A type set literal of the form ~T and A|B may only appear as constraint;
608 // embed it in an implicit interface so that only interface type-checking
609 // needs to take care of such type expressions.
610 if op, _ := x.(*syntax.Operation); op != nil && (op.Op == syntax.Tilde || op.Op == syntax.Or) {
611 t := check.typ(&syntax.InterfaceType{MethodList: []*syntax.Field{{Type: x}}})
612 // mark t as implicit interface if all went well
613 if t, _ := t.(*Interface); t != nil {
621 func (check *Checker) declareTypeParam(name *syntax.Name) *TypeParam {
622 // Use Typ[Invalid] for the type constraint to ensure that a type
623 // is present even if the actual constraint has not been assigned
625 // TODO(gri) Need to systematically review all uses of type parameter
626 // constraints to make sure we don't rely on them if they
627 // are not properly set yet.
628 tname := NewTypeName(name.Pos(), check.pkg, name.Value, nil)
629 tpar := check.newTypeParam(tname, Typ[Invalid]) // assigns type to tname as a side-effect
630 check.declare(check.scope, name, tname, check.scope.pos) // TODO(gri) check scope position
634 func (check *Checker) collectMethods(obj *TypeName) {
635 // get associated methods
636 // (Checker.collectObjects only collects methods with non-blank names;
637 // Checker.resolveBaseTypeName ensures that obj is not an alias name
638 // if it has attached methods.)
639 methods := check.methods[obj]
643 delete(check.methods, obj)
644 assert(!check.objMap[obj].tdecl.Alias) // don't use TypeName.IsAlias (requires fully set up object)
646 // use an objset to check for name conflicts
649 // spec: "If the base type is a struct type, the non-blank method
650 // and field names must be distinct."
651 base, _ := obj.typ.(*Named) // shouldn't fail but be conservative
653 assert(base.TypeArgs().Len() == 0) // collectMethods should not be called on an instantiated type
655 // See issue #52529: we must delay the expansion of underlying here, as
656 // base may not be fully set-up.
658 check.checkFieldUniqueness(base)
659 }).describef(obj, "verifying field uniqueness for %v", base)
661 // Checker.Files may be called multiple times; additional package files
662 // may add methods to already type-checked types. Add pre-existing methods
663 // so that we can detect redeclarations.
664 for i := 0; i < base.NumMethods(); i++ {
666 assert(m.name != "_")
667 assert(mset.insert(m) == nil)
672 for _, m := range methods {
673 // spec: "For a base type, the non-blank names of methods bound
674 // to it must be unique."
675 assert(m.name != "_")
676 if alt := mset.insert(m); alt != nil {
678 err.code = _DuplicateMethod
679 if check.conf.CompilerErrorMessages {
680 err.errorf(m.pos, "%s.%s redeclared in this block", obj.Name(), m.name)
682 err.errorf(m.pos, "method %s already declared for %s", m.name, obj)
684 err.recordAltDecl(alt)
695 func (check *Checker) checkFieldUniqueness(base *Named) {
696 if t, _ := base.under().(*Struct); t != nil {
698 for i := 0; i < base.NumMethods(); i++ {
700 assert(m.name != "_")
701 assert(mset.insert(m) == nil)
704 // Check that any non-blank field names of base are distinct from its
706 for _, fld := range t.fields {
708 if alt := mset.insert(fld); alt != nil {
709 // Struct fields should already be unique, so we should only
710 // encounter an alternate via collision with a method name.
713 // For historical consistency, we report the primary error on the
714 // method, and the alt decl on the field.
716 err.code = _DuplicateFieldAndMethod
717 err.errorf(alt, "field and method with the same name %s", fld.name)
718 err.recordAltDecl(fld)
726 func (check *Checker) funcDecl(obj *Func, decl *declInfo) {
727 assert(obj.typ == nil)
729 // func declarations cannot use iota
730 assert(check.iota == nil)
732 sig := new(Signature)
733 obj.typ = sig // guard against cycles
735 // Avoid cycle error when referring to method while type-checking the signature.
736 // This avoids a nuisance in the best case (non-parameterized receiver type) and
737 // since the method is not a type, we get an error. If we have a parameterized
738 // receiver type, instantiating the receiver type leads to the instantiation of
739 // its methods, and we don't want a cycle error in that case.
740 // TODO(gri) review if this is correct and/or whether we still need this?
744 check.funcType(sig, fdecl.Recv, fdecl.TParamList, fdecl.Type)
747 if len(fdecl.TParamList) > 0 && fdecl.Body == nil {
748 check.softErrorf(fdecl, _BadDecl, "parameterized function is missing function body")
751 // function body must be type-checked after global declarations
752 // (functions implemented elsewhere have no body)
753 if !check.conf.IgnoreFuncBodies && fdecl.Body != nil {
755 check.funcBody(decl, obj.name, sig, fdecl.Body, nil)
756 }).describef(obj, "func %s", obj.name)
760 func (check *Checker) declStmt(list []syntax.Decl) {
763 first := -1 // index of first ConstDecl in the current group, or -1
764 var last *syntax.ConstDecl // last ConstDecl with init expressions, or nil
765 for index, decl := range list {
766 if _, ok := decl.(*syntax.ConstDecl); !ok {
767 first = -1 // we're not in a constant declaration
770 switch s := decl.(type) {
771 case *syntax.ConstDecl:
772 top := len(check.delayed)
774 // iota is the index of the current constDecl within the group
775 if first < 0 || s.Group == nil || list[index-1].(*syntax.ConstDecl).Group != s.Group {
779 iota := constant.MakeInt64(int64(index - first))
781 // determine which initialization expressions to use
784 case s.Type != nil || s.Values != nil:
788 last = new(syntax.ConstDecl) // make sure last exists
792 // declare all constants
793 lhs := make([]*Const, len(s.NameList))
794 values := unpackExpr(last.Values)
795 for i, name := range s.NameList {
796 obj := NewConst(name.Pos(), pkg, name.Value, nil, iota)
804 check.constDecl(obj, last.Type, init, inherited)
807 // Constants must always have init values.
808 check.arity(s.Pos(), s.NameList, values, true, inherited)
810 // process function literals in init expressions before scope changes
811 check.processDelayed(top)
813 // spec: "The scope of a constant or variable identifier declared
814 // inside a function begins at the end of the ConstSpec or VarSpec
815 // (ShortVarDecl for short variable declarations) and ends at the
816 // end of the innermost containing block."
817 scopePos := syntax.EndPos(s)
818 for i, name := range s.NameList {
819 check.declare(check.scope, name, lhs[i], scopePos)
822 case *syntax.VarDecl:
823 top := len(check.delayed)
825 lhs0 := make([]*Var, len(s.NameList))
826 for i, name := range s.NameList {
827 lhs0[i] = NewVar(name.Pos(), pkg, name.Value, nil)
830 // initialize all variables
831 values := unpackExpr(s.Values)
832 for i, obj := range lhs0 {
836 case len(s.NameList):
840 // rhs is expected to be a multi-valued expression
848 check.varDecl(obj, lhs, s.Type, init)
849 if len(values) == 1 {
850 // If we have a single lhs variable we are done either way.
851 // If we have a single rhs expression, it must be a multi-
852 // valued expression, in which case handling the first lhs
853 // variable will cause all lhs variables to have a type
854 // assigned, and we are done as well.
856 for _, obj := range lhs0 {
857 assert(obj.typ != nil)
864 // If we have no type, we must have values.
865 if s.Type == nil || values != nil {
866 check.arity(s.Pos(), s.NameList, values, false, false)
869 // process function literals in init expressions before scope changes
870 check.processDelayed(top)
872 // declare all variables
873 // (only at this point are the variable scopes (parents) set)
874 scopePos := syntax.EndPos(s) // see constant declarations
875 for i, name := range s.NameList {
876 // see constant declarations
877 check.declare(check.scope, name, lhs0[i], scopePos)
880 case *syntax.TypeDecl:
881 obj := NewTypeName(s.Name.Pos(), pkg, s.Name.Value, nil)
882 // spec: "The scope of a type identifier declared inside a function
883 // begins at the identifier in the TypeSpec and ends at the end of
884 // the innermost containing block."
885 scopePos := s.Name.Pos()
886 check.declare(check.scope, s.Name, obj, scopePos)
887 // mark and unmark type before calling typeDecl; its type is still nil (see Checker.objDecl)
888 obj.setColor(grey + color(check.push(obj)))
889 check.typeDecl(obj, s, nil)
890 check.pop().setColor(black)
893 check.errorf(s, 0, invalidAST+"unknown syntax.Decl node %T", s)