@@ -455,9 +455,6 @@ func (tc *typechecker) typeof(expr ast.Expression, typeExpected bool) *typeInfo
455455 }
456456 return t
457457
458- case * ast.DollarIdentifier :
459- return tc .checkDollarIdentifier (expr )
460-
461458 case * ast.Identifier :
462459 return tc .checkIdentifier (expr , true )
463460
@@ -2208,51 +2205,6 @@ func (tc *typechecker) isCompileConstant(expr ast.Expression) bool {
22082205 return true
22092206}
22102207
2211- // checkDollarIdentifier type checks a dollar identifier $x.
2212- func (tc * typechecker ) checkDollarIdentifier (expr * ast.DollarIdentifier ) * typeInfo {
2213-
2214- // Check that x is a valid identifier.
2215- if ti , _ , ok := tc .scopes .Lookup (expr .Ident .Name ); ok {
2216- // Check that x is not a builtin function.
2217- if ti .IsBuiltinFunction () {
2218- panic (tc .errorf (expr .Ident , "use of builtin %s not in function call" , expr .Ident ))
2219- }
2220- // Check that x is not a type.
2221- if ti .IsType () {
2222- panic (tc .errorf (expr .Ident , "unexpected type in dollar identifier" ))
2223- }
2224- // Check that x is not a local identifier.
2225- if _ , _ , ok := tc .scopes .LookupInFunc (expr .Ident .Name ); ok {
2226- panic (tc .errorf (expr , "use of local identifier within dollar identifier" ))
2227- }
2228- // Check that x is not declared in the file/package block, that
2229- // contains, for example, the variable declarations at the top level of
2230- // an imported or extending file.
2231- if _ , ok := tc .scopes .FilePackage (expr .Ident .Name ); ok {
2232- panic (tc .errorf (expr , "use of top-level identifier within dollar identifier" ))
2233- }
2234- }
2235-
2236- // Set the IR of the expression.
2237- var arg * ast.Identifier
2238- var pos = expr .Pos ()
2239- if _ , ok := tc .scopes .Global (expr .Ident .Name ); ok {
2240- arg = expr .Ident // "x"
2241- } else {
2242- arg = ast .NewIdentifier (pos , "nil" ) // "nil"
2243- }
2244- // expr.IR.Ident is set to "interface{}(x)" or "interface{}(nil)".
2245- expr .IR .Ident = ast .NewCall (
2246- pos ,
2247- ast .NewInterface (pos ), // "interface{}"
2248- []ast.Expression {arg }, // "x" or "nil"
2249- false ,
2250- )
2251-
2252- // Type check the IR of the expression and return its type info.
2253- return tc .checkExpr (expr .IR .Ident )
2254- }
2255-
22562208// checkDefault type checks a default expression. show indicates if the
22572209// default expression is in a show statement.
22582210func (tc * typechecker ) checkDefault (expr * ast.Default , show bool ) typeInfoPair {
0 commit comments