if (c->activation) {
bool hasProperty = false;
Value v = c->activation->get(c, name, &hasProperty);
- if (hasProperty)
+ if (hasProperty) {
+ *base = c->activation;
return v;
+ }
}
if (f->function && f->function->isNamedExpression
&& name->isEqualTo(f->function->name))
throwError(Value::fromObject(engine->newTypeErrorObject(QStringLiteral("Type error"))));
}
+void ExecutionContext::throwTypeError(const QString &message)
+{
+ throwError(Value::fromObject(engine->newTypeErrorObject(message)));
+}
+
void ExecutionContext::throwUnimplemented(const QString &message)
{
Value v = Value::fromString(this, QStringLiteral("Unimplemented ") + message);
void Q_NORETURN throwError(const QString &message);
void Q_NORETURN throwSyntaxError(DiagnosticMessage *message);
void Q_NORETURN throwTypeError();
+ void Q_NORETURN throwTypeError(const QString &message);
void Q_NORETURN throwReferenceError(Value value);
void Q_NORETURN throwRangeError(Value value);
void Q_NORETURN throwURIError(Value msg);
Object *base;
Value func = context->getPropertyAndBase(name, &base);
FunctionObject *o = func.asFunctionObject();
- if (!o)
- context->throwTypeError();
+ if (!o) {
+ QString objectAsString = QStringLiteral("[null]");
+ if (base)
+ objectAsString = Value::fromObject(base).toQString();
+ QString msg = QStringLiteral("Property '%1' of object %2 is not a function").arg(name->toQString()).arg(objectAsString);
+ context->throwTypeError(msg);
+ }
Value thisObject = base ? Value::fromObject(base) : Value::undefinedValue();