github.com/goplus/gop@v1.2.6/x/typesutil/eval.go (about)

     1  /*
     2   * Copyright (c) 2023 The GoPlus Authors (goplus.org). All rights reserved.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package typesutil
    18  
    19  import (
    20  	"go/types"
    21  
    22  	"github.com/goplus/gop/ast"
    23  	"github.com/goplus/gop/token"
    24  )
    25  
    26  // CheckExpr type checks the expression expr as if it had appeared at position
    27  // pos of package pkg. Type information about the expression is recorded in
    28  // info. The expression may be an identifier denoting an uninstantiated generic
    29  // function or type.
    30  //
    31  // If pkg == nil, the Universe scope is used and the provided
    32  // position pos is ignored. If pkg != nil, and pos is invalid,
    33  // the package scope is used. Otherwise, pos must belong to the
    34  // package.
    35  //
    36  // An error is returned if pos is not within the package or
    37  // if the node cannot be type-checked.
    38  //
    39  // Note: Eval and CheckExpr should not be used instead of running Check
    40  // to compute types and values, but in addition to Check, as these
    41  // functions ignore the context in which an expression is used (e.g., an
    42  // assignment). Thus, top-level untyped constants will return an
    43  // untyped type rather than the respective context-specific type.
    44  func CheckExpr(fset *token.FileSet, pkg *types.Package, pos token.Pos, expr ast.Expr, info *Info) (err error) {
    45  	panic("todo")
    46  }