pulumi/pkg/compiler/errors/binder.go

52 lines
4.1 KiB
Go
Raw Normal View History

2017-06-26 23:46:34 +02:00
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
package errors
// Binder errors are in the [500-600) range.
var (
ErrorInvalidPackageName = newError(500, "The package name must be a valid identifier")
Implement dynamic loads from the environment¬ This rearranges the way dynamic loads work a bit. Previously, they¬ required an object, and did a dynamic lookup in the object's property¬ map. For real dynamic loads -- of the kind Python uses, obviously,¬ but also ECMAScript -- we need to search the "environment". This change searches the environment by looking first in the lexical¬ scope in the current function. If a variable exists, we will use it.¬ If that misses, we then look in the module scope. If a variable exists¬ there, we will use it. Otherwise, if the variable is used in a non-lval position, an dynamic error will be raised ("name not declared"). If an lval, however, we will lazily allocate a slot for it. Note that Python doesn't use block scoping in the same way that most languages do. This behavior is simply achieved by Python not emitting any lexically scoped blocks other than at the function level. This doesn't perfectly achieve the scoping behavior, because we don't yet bind every name in a way that they can be dynamically discovered. The two obvious cases are class names and import names. Those will be covered in a subsequent commit. Also note that we are getting lucky here that class static/instance variables aren't accessible in Python or ECMAScript "ambiently" like they are in some languages (e.g., C#, Java); as a result, we don't need to introduce a class scope in the dynamic lookup. Some day, when we want to support such languages, we'll need to think about how to let languages control the environment probe order; for instance, perhaps the LoadDynamicExpression node can have an "environment" property.
2017-04-09 01:47:15 +02:00
ErrorMalformedToken = newError(501, "%v token '%v' is malformed: %v")
ErrorMalformedPackageURL = newError(502, "Package URL '%v' is malformed: %v")
ErrorImportNotFound = newError(503, "The imported package '%v' was not found; has it been installed?%v")
ErrorTypeNotFound = newError(504, "Type '%v' could not be found: %v")
ErrorSymbolNotFound = newError(505, "Symbol '%v' could not be found: %v")
ErrorSymbolAlreadyExists = newError(506, "A symbol already exists with the name '%v'")
ErrorIncorrectExprType = newError(507, "Expression has the wrong type; expected '%v', got '%v'")
ErrorMemberNotAccessible = newError(508, "Member '%v' is not accessible (it is %v)")
ErrorExpectedReturnExpr = newError(509, "Expected a return expression of type '%v'")
ErrorUnexpectedReturnExpr = newError(510, "Unexpected return expression; function has no return type (void)")
ErrorDuplicateLabel = newError(511, "Duplicate label '%v': %v")
ErrorUnknownJumpLabel = newError(512, "Unknown label '%v' used in the %v statement")
ErrorCannotNewAbstractClass = newError(513, "Cannot `new` an abstract class '%v'")
ErrorIllegalObjectLiteralType = newError(514,
"The type '%v' may not be used as an object literal type; only records and interfaces are permitted")
Implement dynamic loads from the environment¬ This rearranges the way dynamic loads work a bit. Previously, they¬ required an object, and did a dynamic lookup in the object's property¬ map. For real dynamic loads -- of the kind Python uses, obviously,¬ but also ECMAScript -- we need to search the "environment". This change searches the environment by looking first in the lexical¬ scope in the current function. If a variable exists, we will use it.¬ If that misses, we then look in the module scope. If a variable exists¬ there, we will use it. Otherwise, if the variable is used in a non-lval position, an dynamic error will be raised ("name not declared"). If an lval, however, we will lazily allocate a slot for it. Note that Python doesn't use block scoping in the same way that most languages do. This behavior is simply achieved by Python not emitting any lexically scoped blocks other than at the function level. This doesn't perfectly achieve the scoping behavior, because we don't yet bind every name in a way that they can be dynamically discovered. The two obvious cases are class names and import names. Those will be covered in a subsequent commit. Also note that we are getting lucky here that class static/instance variables aren't accessible in Python or ECMAScript "ambiently" like they are in some languages (e.g., C#, Java); as a result, we don't need to introduce a class scope in the dynamic lookup. Some day, when we want to support such languages, we'll need to think about how to let languages control the environment probe order; for instance, perhaps the LoadDynamicExpression node can have an "environment" property.
2017-04-09 01:47:15 +02:00
ErrorMissingRequiredProperty = newError(515, "Missing required property '%v'")
ErrorUnaryOperatorInvalidForType = newError(516,
"The operator %v is invalid on operand type '%v'; expected '%v'")
Implement dynamic loads from the environment¬ This rearranges the way dynamic loads work a bit. Previously, they¬ required an object, and did a dynamic lookup in the object's property¬ map. For real dynamic loads -- of the kind Python uses, obviously,¬ but also ECMAScript -- we need to search the "environment". This change searches the environment by looking first in the lexical¬ scope in the current function. If a variable exists, we will use it.¬ If that misses, we then look in the module scope. If a variable exists¬ there, we will use it. Otherwise, if the variable is used in a non-lval position, an dynamic error will be raised ("name not declared"). If an lval, however, we will lazily allocate a slot for it. Note that Python doesn't use block scoping in the same way that most languages do. This behavior is simply achieved by Python not emitting any lexically scoped blocks other than at the function level. This doesn't perfectly achieve the scoping behavior, because we don't yet bind every name in a way that they can be dynamically discovered. The two obvious cases are class names and import names. Those will be covered in a subsequent commit. Also note that we are getting lucky here that class static/instance variables aren't accessible in Python or ECMAScript "ambiently" like they are in some languages (e.g., C#, Java); as a result, we don't need to introduce a class scope in the dynamic lookup. Some day, when we want to support such languages, we'll need to think about how to let languages control the environment probe order; for instance, perhaps the LoadDynamicExpression node can have an "environment" property.
2017-04-09 01:47:15 +02:00
ErrorUnaryOperatorInvalidForOperand = newError(517, "The operator %v is invalid on operand %v; expected %v")
ErrorUnaryOperatorMustBePrefix = newError(518, "The operator %v must be in a prefix position (not postfix)")
ErrorBinaryOperatorInvalidForType = newError(519,
"The operator %v is invalid on %v operand type '%v'; expected '%v'")
Implement dynamic loads from the environment¬ This rearranges the way dynamic loads work a bit. Previously, they¬ required an object, and did a dynamic lookup in the object's property¬ map. For real dynamic loads -- of the kind Python uses, obviously,¬ but also ECMAScript -- we need to search the "environment". This change searches the environment by looking first in the lexical¬ scope in the current function. If a variable exists, we will use it.¬ If that misses, we then look in the module scope. If a variable exists¬ there, we will use it. Otherwise, if the variable is used in a non-lval position, an dynamic error will be raised ("name not declared"). If an lval, however, we will lazily allocate a slot for it. Note that Python doesn't use block scoping in the same way that most languages do. This behavior is simply achieved by Python not emitting any lexically scoped blocks other than at the function level. This doesn't perfectly achieve the scoping behavior, because we don't yet bind every name in a way that they can be dynamically discovered. The two obvious cases are class names and import names. Those will be covered in a subsequent commit. Also note that we are getting lucky here that class static/instance variables aren't accessible in Python or ECMAScript "ambiently" like they are in some languages (e.g., C#, Java); as a result, we don't need to introduce a class scope in the dynamic lookup. Some day, when we want to support such languages, we'll need to think about how to let languages control the environment probe order; for instance, perhaps the LoadDynamicExpression node can have an "environment" property.
2017-04-09 01:47:15 +02:00
ErrorIllegalAssignmentLValue = newError(520, "Cannot assign to the target LHS expression (not an l-value)")
ErrorIllegalNumericAssignmentLValue = newError(521, "Cannot perform numeric assignment %v on a non-numeric LHS")
ErrorIllegalAssignmentTypes = newError(522, "Cannot assign a value of type '%v' to target of type '%v'")
ErrorCannotInvokeNonFunction = newError(523, "Cannot invoke a non-function; type '%v' is not a function")
ErrorArgumentCountMismatch = newError(524, "Function expects %v arguments; got %v instead")
ErrorConstructorReturnType = newError(525, "Constructor '%v' has a return type '%v'; should be nil (void)")
ErrorConstructorNotMethod = newError(526, "Constructor '%v' is not a method; got %v instead")
ErrorExpectedObject = newError(527,
"Expected an object target for this instance member load operation")
Implement dynamic loads from the environment¬ This rearranges the way dynamic loads work a bit. Previously, they¬ required an object, and did a dynamic lookup in the object's property¬ map. For real dynamic loads -- of the kind Python uses, obviously,¬ but also ECMAScript -- we need to search the "environment". This change searches the environment by looking first in the lexical¬ scope in the current function. If a variable exists, we will use it.¬ If that misses, we then look in the module scope. If a variable exists¬ there, we will use it. Otherwise, if the variable is used in a non-lval position, an dynamic error will be raised ("name not declared"). If an lval, however, we will lazily allocate a slot for it. Note that Python doesn't use block scoping in the same way that most languages do. This behavior is simply achieved by Python not emitting any lexically scoped blocks other than at the function level. This doesn't perfectly achieve the scoping behavior, because we don't yet bind every name in a way that they can be dynamically discovered. The two obvious cases are class names and import names. Those will be covered in a subsequent commit. Also note that we are getting lucky here that class static/instance variables aren't accessible in Python or ECMAScript "ambiently" like they are in some languages (e.g., C#, Java); as a result, we don't need to introduce a class scope in the dynamic lookup. Some day, when we want to support such languages, we'll need to think about how to let languages control the environment probe order; for instance, perhaps the LoadDynamicExpression node can have an "environment" property.
2017-04-09 01:47:15 +02:00
ErrorUnexpectedObject = newError(528,
"Unexpected object target for this static or module load operation")
Implement dynamic loads from the environment¬ This rearranges the way dynamic loads work a bit. Previously, they¬ required an object, and did a dynamic lookup in the object's property¬ map. For real dynamic loads -- of the kind Python uses, obviously,¬ but also ECMAScript -- we need to search the "environment". This change searches the environment by looking first in the lexical¬ scope in the current function. If a variable exists, we will use it.¬ If that misses, we then look in the module scope. If a variable exists¬ there, we will use it. Otherwise, if the variable is used in a non-lval position, an dynamic error will be raised ("name not declared"). If an lval, however, we will lazily allocate a slot for it. Note that Python doesn't use block scoping in the same way that most languages do. This behavior is simply achieved by Python not emitting any lexically scoped blocks other than at the function level. This doesn't perfectly achieve the scoping behavior, because we don't yet bind every name in a way that they can be dynamically discovered. The two obvious cases are class names and import names. Those will be covered in a subsequent commit. Also note that we are getting lucky here that class static/instance variables aren't accessible in Python or ECMAScript "ambiently" like they are in some languages (e.g., C#, Java); as a result, we don't need to introduce a class scope in the dynamic lookup. Some day, when we want to support such languages, we'll need to think about how to let languages control the environment probe order; for instance, perhaps the LoadDynamicExpression node can have an "environment" property.
2017-04-09 01:47:15 +02:00
ErrorInvalidCast = newError(529, "Illegal cast from '%v' to '%v'; this can never succeed")
ErrorModuleAliasTargetNotFound = newError(530, "Module alias target '%v' was not found (from '%v')")
ErrorDerivedClassHasNoCtor = newError(531, "Class '%v' has no constructor, but its base class '%v' does")
ErrorSequencePreludeExprStmt = newError(532, "Sequence preludes must consist of expressions and/or statements")
ErrorPropertyGetterParamCount = newError(533, "Property getter must not have any parameters; got %v")
ErrorPropertyGetterReturnType = newError(534, "Property getter returned type '%v'; expected '%v'")
ErrorPropertySetterParamCount = newError(535, "Property setter must have exactly 1 parameter; got %v")
ErrorPropertySetterParamType = newError(536, "Property setter parameter is type '%v'; expected '%v'")
2017-05-16 02:50:13 +02:00
ErrorPropertySetterReturnType = newError(537, "Property setter returned type '%v'; expected no return type")
ErrorMethodsMustHaveBodies = newError(538, "Non-abstract methods must have bodies: '%v' is %v")
)