public override bool check (CodeContext context) {
if (invalid_syntax) {
- Report.error (source_reference, "syntax error, no expression allowed between array brackets");
+ context.report.log_error (source_reference, "syntax error, no expression allowed between array brackets");
error = true;
return false;
}
if (length.value_type == null || !(length.value_type is IntegerType || length.value_type is EnumValueType)
|| !length.is_constant ()) {
error = true;
- Report.error (length.source_reference, "Expression of constant integer type expected");
+ context.report.log_error (length.source_reference, "Expression of constant integer type expected");
return false;
}
}
if (element_type is ArrayType) {
error = true;
- Report.error (source_reference, "Stacked arrays are not supported");
+ context.report.log_error (source_reference, "Stacked arrays are not supported");
return false;
} else if (element_type is DelegateType) {
var delegate_type = (DelegateType) element_type;
if (delegate_type.delegate_symbol.has_target) {
error = true;
- Report.error (source_reference, "Delegates with target are not supported as array element type");
+ context.report.log_error (source_reference, "Delegates with target are not supported as array element type");
return false;
}
}
length_type.check (context);
if (!(length_type is IntegerType) || length_type.nullable) {
error = true;
- Report.error (length_type.source_reference, "Expected integer type as length type of array");
+ context.report.log_error (length_type.source_reference, "Expected integer type as length type of array");
return false;
}
}
if ((!(ma.symbol_reference is DynamicProperty) && ma.value_type == null) ||
(ma.inner == null && ma.member_name == "this" && context.analyzer.is_in_instance_method ())) {
error = true;
- Report.error (source_reference, "unsupported lvalue in assignment");
+ context.report.log_error (source_reference, "unsupported lvalue in assignment");
return false;
}
if (ma.prototype_access) {
error = true;
- Report.error (source_reference, "Access to instance member `%s' denied", ma.symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Access to instance member `%s' denied", ma.symbol_reference.get_full_name ());
return false;
}
if (ma.symbol_reference.get_attribute ("GtkChild") != null) {
error = true;
- Report.error (source_reference, "Assignment of [GtkChild] `%s' is not allowed", ma.symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Assignment of [GtkChild] `%s' is not allowed", ma.symbol_reference.get_full_name ());
return false;
}
if (ea.container.value_type.type_symbol == context.analyzer.string_type.type_symbol) {
error = true;
- Report.error (ea.source_reference, "strings are immutable");
+ context.report.log_error (ea.source_reference, "strings are immutable");
return false;
} else if (ea.container.value_type.get_member ("set") is Method) {
var set_call = new MethodCall (new MemberAccess (ea.container, "set", source_reference), source_reference);
right.target_type = left.value_type.copy ();
} else if (left is Literal) {
error = true;
- Report.error (source_reference, "Literals are immutable");
+ context.report.log_error (source_reference, "Literals are immutable");
return false;
} else {
error = true;
- Report.error (source_reference, "unsupported lvalue in assignment");
+ context.report.log_error (source_reference, "unsupported lvalue in assignment");
return false;
}
case AssignmentOperator.SHIFT_RIGHT: bop = BinaryOperator.SHIFT_RIGHT; break;
default:
error = true;
- Report.error (source_reference, "internal error: unsupported assignment operator");
+ context.report.log_error (source_reference, "internal error: unsupported assignment operator");
return false;
}
}
} else if (ma.symbol_reference is ArrayLengthField && ((ArrayType) ma.inner.value_type).inline_allocated) {
error = true;
- Report.error (source_reference, "`length' field of fixed length arrays is read-only");
+ context.report.log_error (source_reference, "`length' field of fixed length arrays is read-only");
return false;
} else if (ma.symbol_reference is Variable && right.value_type is MethodType) {
unowned Variable variable = (Variable) ma.symbol_reference;
unowned Method m = (Method) right.symbol_reference;
unowned Delegate cb = ((DelegateType) variable.variable_type).delegate_symbol;
error = true;
- Report.error (source_reference, "Declaration of method `%s' is not compatible with delegate `%s'", m.get_full_name (), cb.get_full_name ());
+ context.report.log_error (source_reference, "Declaration of method `%s' is not compatible with delegate `%s'", m.get_full_name (), cb.get_full_name ());
return false;
}
} else {
error = true;
- Report.error (source_reference, "Assignment: Invalid assignment attempt");
+ context.report.log_error (source_reference, "Assignment: Invalid assignment attempt");
return false;
}
} else if (ma.symbol_reference is Variable && right.value_type == null) {
error = true;
- Report.error (source_reference, "Assignment: Invalid assignment attempt");
+ context.report.log_error (source_reference, "Assignment: Invalid assignment attempt");
return false;
} else if (ma.symbol_reference is Variable) {
unowned Variable variable = (Variable) ma.symbol_reference;
if (!right.value_type.compatible (left.value_type)) {
error = true;
- Report.error (source_reference, "Assignment: Cannot convert from `%s' to `%s'", right.value_type.to_string (), left.value_type.to_string ());
+ context.report.log_error (source_reference, "Assignment: Cannot convert from `%s' to `%s'", right.value_type.to_string (), left.value_type.to_string ());
return false;
} else if (left.value_type is EnumValueType && right.value_type is IntegerType
&& (!(right is IntegerLiteral) || ((IntegerLiteral) right).value != "0")) {
if (!(left.value_type is PointerType) && !left.value_type.value_owned) {
/* lhs doesn't own the value */
error = true;
- Report.error (source_reference, "Invalid assignment from owned expression to unowned variable");
+ context.report.log_error (source_reference, "Invalid assignment from owned expression to unowned variable");
}
} else if (left.value_type.value_owned) {
/* lhs wants to own the value
if (!right.value_type.compatible (left.value_type)) {
error = true;
- Report.error (source_reference, "Assignment: Cannot convert from `%s' to `%s'", right.value_type.to_string (), left.value_type.to_string ());
+ context.report.log_error (source_reference, "Assignment: Cannot convert from `%s' to `%s'", right.value_type.to_string (), left.value_type.to_string ());
return false;
}
if (!(element_type is PointerType) && !element_type.value_owned) {
/* lhs doesn't own the value */
error = true;
- Report.error (source_reference, "Invalid assignment from owned expression to unowned variable");
+ context.report.log_error (source_reference, "Invalid assignment from owned expression to unowned variable");
return false;
}
} else if (left.value_type.value_owned) {
if (!context.analyzer.is_in_instance_method ()) {
error = true;
- Report.error (source_reference, "Base access invalid outside of instance methods");
+ context.report.log_error (source_reference, "Base access invalid outside of instance methods");
return false;
}
if (context.analyzer.current_class == null) {
if (context.analyzer.current_struct == null) {
error = true;
- Report.error (source_reference, "Base access invalid outside of class and struct");
+ context.report.log_error (source_reference, "Base access invalid outside of class and struct");
return false;
} else if (context.analyzer.current_struct.base_type == null) {
error = true;
- Report.error (source_reference, "Base access invalid without base type");
+ context.report.log_error (source_reference, "Base access invalid without base type");
return false;
}
value_type = context.analyzer.current_struct.base_type;
} else if (context.analyzer.current_class.base_class == null) {
error = true;
- Report.error (source_reference, "Base access invalid without base class");
+ context.report.log_error (source_reference, "Base access invalid without base class");
return false;
} else if (context.analyzer.current_class.is_compact && context.analyzer.current_method != null
&& !(context.analyzer.current_method is CreationMethod)
&& (context.analyzer.current_method.overrides || context.analyzer.current_method.is_virtual)) {
error = true;
- Report.error (source_reference, "Base access invalid in virtual overridden method of compact class");
+ context.report.log_error (source_reference, "Base access invalid in virtual overridden method of compact class");
return false;
} else if (context.analyzer.current_class.is_compact && context.analyzer.current_property_accessor != null
&& (context.analyzer.current_property_accessor.prop.overrides || context.analyzer.current_property_accessor.prop.is_virtual)) {
error = true;
- Report.error (source_reference, "Base access invalid in virtual overridden property of compact class");
+ context.report.log_error (source_reference, "Base access invalid in virtual overridden property of compact class");
return false;
} else {
foreach (var base_type in context.analyzer.current_class.get_base_types ()) {
}
if (left.value_type == null) {
- Report.error (left.source_reference, "invalid left operand");
+ context.report.log_error (left.source_reference, "invalid left operand");
error = true;
return false;
}
if (operator != BinaryOperator.IN && right.value_type == null) {
- Report.error (right.source_reference, "invalid right operand");
+ context.report.log_error (right.source_reference, "invalid right operand");
error = true;
return false;
}
if (left.value_type is FieldPrototype || left.value_type is PropertyPrototype) {
error = true;
- Report.error (left.source_reference, "Access to instance member `%s' denied", left.symbol_reference.get_full_name ());
+ context.report.log_error (left.source_reference, "Access to instance member `%s' denied", left.symbol_reference.get_full_name ());
return false;
}
if (right.value_type is FieldPrototype || right.value_type is PropertyPrototype) {
error = true;
- Report.error (right.source_reference, "Access to instance member `%s' denied", right.symbol_reference.get_full_name ());
+ context.report.log_error (right.source_reference, "Access to instance member `%s' denied", right.symbol_reference.get_full_name ());
return false;
}
|| left is NullLiteral || right is NullLiteral) {
// operands cannot be null
error = true;
- Report.error (source_reference, "Operands must be strings");
+ context.report.log_error (source_reference, "Operands must be strings");
return false;
}
if (array_type.inline_allocated) {
error = true;
- Report.error (source_reference, "Array concatenation not supported for fixed length arrays");
+ context.report.log_error (source_reference, "Array concatenation not supported for fixed length arrays");
}
if (right.value_type == null || !right.value_type.compatible (array_type.element_type)) {
error = true;
- Report.error (source_reference, "Incompatible operand");
+ context.report.log_error (source_reference, "Incompatible operand");
return false;
}
unowned PointerType pointer_type = (PointerType) left.value_type;
if (pointer_type.base_type is VoidType) {
error = true;
- Report.error (source_reference, "Pointer arithmetic not supported for `void*'");
+ context.report.log_error (source_reference, "Pointer arithmetic not supported for `void*'");
return false;
}
if (value_type == null) {
error = true;
- Report.error (source_reference, "Arithmetic operation not supported for types `%s' and `%s'", left.value_type.to_string (), right.value_type.to_string ());
+ context.report.log_error (source_reference, "Arithmetic operation not supported for types `%s' and `%s'", left.value_type.to_string (), right.value_type.to_string ());
return false;
}
break;
if (value_type == null) {
error = true;
- Report.error (source_reference, "Arithmetic operation not supported for types `%s' and `%s'", left.value_type.to_string (), right.value_type.to_string ());
+ context.report.log_error (source_reference, "Arithmetic operation not supported for types `%s' and `%s'", left.value_type.to_string (), right.value_type.to_string ());
return false;
}
break;
if (resulting_type == null) {
error = true;
- Report.error (source_reference, "Relational operation not supported for types `%s' and `%s'", left.value_type.to_string (), right.value_type.to_string ());
+ context.report.log_error (source_reference, "Relational operation not supported for types `%s' and `%s'", left.value_type.to_string (), right.value_type.to_string ());
return false;
}
if (!right.value_type.compatible (left.value_type)
&& !left.value_type.compatible (right.value_type)) {
- Report.error (source_reference, "Equality operation: `%s' and `%s' are incompatible", right.value_type.to_string (), left.value_type.to_string ());
+ context.report.log_error (source_reference, "Equality operation: `%s' and `%s' are incompatible", right.value_type.to_string (), left.value_type.to_string ());
error = true;
return false;
}
case BinaryOperator.OR:
if (!left.value_type.compatible (context.analyzer.bool_type) || !right.value_type.compatible (context.analyzer.bool_type)) {
error = true;
- Report.error (source_reference, "Operands must be boolean");
+ context.report.log_error (source_reference, "Operands must be boolean");
}
left.target_type.nullable = false;
right.target_type.nullable = false;
if (left.value_type.type_symbol is Enum && right.value_type.type_symbol is Enum
&& left.value_type.type_symbol != right.value_type.type_symbol) {
error = true;
- Report.error (source_reference, "Cannot look for `%s' in `%s'", left.value_type.to_string (), right.value_type.to_string ());
+ context.report.log_error (source_reference, "Cannot look for `%s' in `%s'", left.value_type.to_string (), right.value_type.to_string ());
}
} else if (right.value_type is ArrayType) {
if (!left.value_type.compatible (((ArrayType) right.value_type).element_type)) {
error = true;
- Report.error (source_reference, "Cannot look for `%s' in `%s'", left.value_type.to_string (), right.value_type.to_string ());
+ context.report.log_error (source_reference, "Cannot look for `%s' in `%s'", left.value_type.to_string (), right.value_type.to_string ());
}
} else {
// otherwise require a bool contains () method
var contains_method = right.value_type.get_member ("contains") as Method;
if (contains_method == null) {
- Report.error (source_reference, "`%s' does not have a `contains' method", right.value_type.to_string ());
+ context.report.log_error (source_reference, "`%s' does not have a `contains' method", right.value_type.to_string ());
error = true;
return false;
}
if (contains_method.get_parameters ().size != 1) {
- Report.error (source_reference, "`%s' must have one parameter", contains_method.get_full_name ());
+ context.report.log_error (source_reference, "`%s' must have one parameter", contains_method.get_full_name ());
error = true;
return false;
}
if (!contains_method.return_type.compatible (context.analyzer.bool_type)) {
- Report.error (source_reference, "`%s' must return a boolean value", contains_method.get_full_name ());
+ context.report.log_error (source_reference, "`%s' must return a boolean value", contains_method.get_full_name ());
error = true;
return false;
}
break;
default:
error = true;
- Report.error (source_reference, "internal error: unsupported binary operator");
+ context.report.log_error (source_reference, "internal error: unsupported binary operator");
return false;
}
}
if (inner.value_type == null) {
- Report.error (source_reference, "Invalid cast expression");
+ context.report.log_error (source_reference, "Invalid cast expression");
error = true;
return false;
}
// FIXME: check whether cast is allowed
if (type_reference is VoidType) {
- Report.error (source_reference, "Casting to `void' is not allowed");
+ context.report.log_error (source_reference, "Casting to `void' is not allowed");
error = true;
return false;
}
if (!type_reference.is_real_struct_type () && inner.value_type.is_real_struct_type ()
&& (context.profile != Profile.GOBJECT || !(is_gvariant (context, inner.value_type) || is_gvalue (context, inner.value_type)))) {
error = true;
- Report.error (source_reference, "Casting of struct `%s' to `%s' is not allowed", inner.value_type.to_qualified_string (), type_reference.to_qualified_string ());
+ context.report.log_error (source_reference, "Casting of struct `%s' to `%s' is not allowed", inner.value_type.to_qualified_string (), type_reference.to_qualified_string ());
}
}
value_type.value_owned = true;
if (value_type.get_type_signature () == null) {
error = true;
- Report.error (source_reference, "Casting of `GLib.Variant' to `%s' is not supported", value_type.to_qualified_string ());
+ context.report.log_error (source_reference, "Casting of `GLib.Variant' to `%s' is not supported", value_type.to_qualified_string ());
}
}
value_type.value_owned = false;
if (value_type.nullable && value_type.type_symbol != null && !value_type.type_symbol.is_reference_type ()) {
error = true;
- Report.error (source_reference, "Casting of `GLib.Value' to `%s' is not supported", value_type.to_qualified_string ());
+ context.report.log_error (source_reference, "Casting of `GLib.Value' to `%s' is not supported", value_type.to_qualified_string ());
}
}
if (!(base_type_reference is ObjectType)) {
error = true;
- Report.error (source_reference, "base type `%s' of class `%s' is not an object type", base_type_reference.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "base type `%s' of class `%s' is not an object type", base_type_reference.to_string (), get_full_name ());
return false;
}
// check whether base type is at least as accessible as the class
if (!base_type_reference.is_accessible (this)) {
error = true;
- Report.error (source_reference, "base type `%s' is less accessible than class `%s'", base_type_reference.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "base type `%s' is less accessible than class `%s'", base_type_reference.to_string (), get_full_name ());
return false;
}
if (base_class != null && base_class.is_singleton) {
error = true;
- Report.error (source_reference, "`%s' cannot inherit from SingleInstance class `%s'", get_full_name (), base_class.get_full_name ());
+ context.report.log_error (source_reference, "`%s' cannot inherit from SingleInstance class `%s'", get_full_name (), base_class.get_full_name ());
}
if (is_singleton && !is_subtype_of (context.analyzer.object_type)) {
error = true;
- Report.error (source_reference, "SingleInstance class `%s' requires inheritance from `GLib.Object'", get_full_name ());
+ context.report.log_error (source_reference, "SingleInstance class `%s' requires inheritance from `GLib.Object'", get_full_name ());
}
/* singleton classes require an instance constructor */
if (base_class != null && base_class.is_sealed) {
error = true;
- Report.error (source_reference, "`%s' cannot inherit from sealed class `%s'", get_full_name (), base_class.get_full_name ());
+ context.report.log_error (source_reference, "`%s' cannot inherit from sealed class `%s'", get_full_name (), base_class.get_full_name ());
}
if (is_sealed) {
if (is_compact) {
error = true;
- Report.error (source_reference, "Sealed class `%s' cannot be compact", get_full_name ());
+ context.report.log_error (source_reference, "Sealed class `%s' cannot be compact", get_full_name ());
return false;
}
if (is_abstract) {
error = true;
- Report.error (source_reference, "Sealed class `%s' cannot be abstract", get_full_name ());
+ context.report.log_error (source_reference, "Sealed class `%s' cannot be abstract", get_full_name ());
return false;
}
}
if (is_compact && f.binding != MemberBinding.STATIC) {
//FIXME Should external bindings follow this too?
if (!external_package && !is_opaque && f.access == SymbolAccessibility.PRIVATE) {
- Report.error (f.source_reference, "private fields are only supported in opaque compact classes, use [Compact (opaque = true)]");
+ context.report.log_error (f.source_reference, "private fields are only supported in opaque compact classes, use [Compact (opaque = true)]");
error = true;
}
if (!external_package && is_opaque && (f.access == SymbolAccessibility.PUBLIC || f.access == SymbolAccessibility.PROTECTED)) {
- Report.error (f.source_reference, "fields in opaque compact classes must be private or internal");
+ context.report.log_error (f.source_reference, "fields in opaque compact classes must be private or internal");
error = true;
}
if (f.binding == MemberBinding.CLASS) {
- Report.error (f.source_reference, "class fields are not supported in compact classes");
+ context.report.log_error (f.source_reference, "class fields are not supported in compact classes");
error = true;
}
}
foreach (Property prop in get_properties ()) {
if (prop.get_attribute ("NoAccessorMethod") != null && !is_subtype_of (context.analyzer.object_type)) {
error = true;
- Report.error (prop.source_reference, "NoAccessorMethod is only allowed for properties in classes derived from GLib.Object");
+ context.report.log_error (prop.source_reference, "NoAccessorMethod is only allowed for properties in classes derived from GLib.Object");
return false;
}
prop.check (context);
foreach (DataType base_type in get_base_types ()) {
if (base_type.type_symbol is Interface) {
error = true;
- Report.error (source_reference, "compact classes `%s' may not implement interfaces", get_full_name ());
+ context.report.log_error (source_reference, "compact classes `%s' may not implement interfaces", get_full_name ());
}
}
foreach (Field f in get_fields ()) {
if (f.binding == MemberBinding.INSTANCE) {
error = true;
- Report.error (source_reference, "derived compact classes may not have instance fields");
+ context.report.log_error (source_reference, "derived compact classes may not have instance fields");
break;
}
}
}
}
error_string += ") are not met";
- Report.error (source_reference, error_string);
+ context.report.log_error (source_reference, error_string);
}
/* VAPI classes don't have to specify overridden methods */
}
if (!implemented) {
error = true;
- Report.error (source_reference, "`%s' does not implement interface method `%s'", get_full_name (), m.get_full_name ());
+ context.report.log_error (source_reference, "`%s' does not implement interface method `%s'", get_full_name (), m.get_full_name ());
}
}
}
// No check at all for "new" classified properties, really?
if (!base_prop.hides && !base_prop.compatible (prop, out invalid_match)) {
error = true;
- Report.error (source_reference, "Type and/or accessors of inherited properties `%s' and `%s' do not match: %s.", prop.get_full_name (), base_prop.get_full_name (), invalid_match);
+ context.report.log_error (source_reference, "Type and/or accessors of inherited properties `%s' and `%s' do not match: %s.", prop.get_full_name (), base_prop.get_full_name (), invalid_match);
}
// property is used as interface implementation, so it is not unused
sym.version.check (context, source_reference);
sym.used = true;
} else {
error = true;
- Report.error (source_reference, "`%s' does not implement interface property `%s'", get_full_name (), prop.get_full_name ());
+ context.report.log_error (source_reference, "`%s' does not implement interface property `%s'", get_full_name (), prop.get_full_name ());
}
}
}
var override_method = SemanticAnalyzer.symbol_lookup_inherited (this, base_method.name) as Method;
if (override_method == null || !override_method.overrides) {
error = true;
- Report.error (source_reference, "`%s' does not implement abstract method `%s'", get_full_name (), base_method.get_full_name ());
+ context.report.log_error (source_reference, "`%s' does not implement abstract method `%s'", get_full_name (), base_method.get_full_name ());
}
}
}
var override_property = SemanticAnalyzer.symbol_lookup_inherited (this, base_property.name) as Property;
if (override_property == null || !override_property.overrides) {
error = true;
- Report.error (source_reference, "`%s' does not implement abstract property `%s'", get_full_name (), base_property.get_full_name ());
+ context.report.log_error (source_reference, "`%s' does not implement abstract property `%s'", get_full_name (), base_property.get_full_name ());
}
}
}
checked = true;
if (!(context.analyzer.current_symbol is Block)) {
- Report.error (source_reference, "Conditional expressions may only be used in blocks");
+ context.report.log_error (source_reference, "Conditional expressions may only be used in blocks");
error = true;
return false;
}
} else {
error = true;
var source_reference = new SourceReference (true_expression.source_reference.file, true_expression.source_reference.begin, false_expression.source_reference.end);
- Report.error (source_reference, "Cannot resolve target type from `%s' and `%s'", true_expression.value_type.to_prototype_string (), false_expression.value_type.to_prototype_string ());
+ context.report.log_error (source_reference, "Cannot resolve target type from `%s' and `%s'", true_expression.value_type.to_prototype_string (), false_expression.value_type.to_prototype_string ());
return false;
}
if (!check_const_type (type_reference, context)) {
error = true;
- Report.error (source_reference, "`%s' not supported as type for constants", type_reference.to_string ());
+ context.report.log_error (source_reference, "`%s' not supported as type for constants", type_reference.to_string ());
return false;
}
// check whether constant type is at least as accessible as the constant
if (!type_reference.is_accessible (this)) {
error = true;
- Report.error (source_reference, "constant type `%s' is less accessible than constant `%s'", type_reference.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "constant type `%s' is less accessible than constant `%s'", type_reference.to_string (), get_full_name ());
}
if (!external) {
// constants from fast-vapi files are special
if (source_type != SourceFileType.FAST) {
error = true;
- Report.error (source_reference, "A const field requires a value to be provided");
+ context.report.log_error (source_reference, "A const field requires a value to be provided");
}
} else {
value.target_type = type_reference;
if (!value.value_type.compatible (type_reference)) {
error = true;
- Report.error (source_reference, "Cannot convert from `%s' to `%s'", value.value_type.to_string (), type_reference.to_string ());
+ context.report.log_error (source_reference, "Cannot convert from `%s' to `%s'", value.value_type.to_string (), type_reference.to_string ());
return false;
}
if (!value.is_constant ()) {
error = true;
- Report.error (value.source_reference, "Value must be constant");
+ context.report.log_error (value.source_reference, "Value must be constant");
return false;
}
// check whether initializer is at least as accessible as the constant
if (!value.is_accessible (this)) {
error = true;
- Report.error (value.source_reference, "value is less accessible than constant `%s'", get_full_name ());
+ context.report.log_error (value.source_reference, "value is less accessible than constant `%s'", get_full_name ());
}
}
} else {
if (value != null) {
error = true;
- Report.error (source_reference, "External constants cannot use values");
+ context.report.log_error (source_reference, "External constants cannot use values");
}
}
if (class_name != null && class_name != parent_symbol.name) {
// class_name is null for constructors generated by GIdlParser
- Report.error (source_reference, "missing return type in method `%s.%s´", context.analyzer.current_symbol.get_full_name (), class_name);
+ context.report.log_error (source_reference, "missing return type in method `%s.%s´", context.analyzer.current_symbol.get_full_name (), class_name);
error = true;
return false;
}
if (coroutine && !external_package && !context.has_package ("gio-2.0")) {
error = true;
- Report.error (source_reference, "gio-2.0 package required for async constructors");
+ context.report.log_error (source_reference, "gio-2.0 package required for async constructors");
return false;
}
}
if (i == 0 && param.ellipsis && body != null) {
error = true;
- Report.error (param.source_reference, "Named parameter required before `...'");
+ context.report.log_error (param.source_reference, "Named parameter required before `...'");
}
i++;
if (param.params_array && body != null) {
if (params_array_var != null) {
error = true;
- Report.error (param.source_reference, "Only one params-array parameter is allowed");
+ context.report.log_error (param.source_reference, "Only one params-array parameter is allowed");
continue;
}
if (!context.experimental) {
type.value_owned = true;
if (type.element_type.is_real_struct_type () && !type.element_type.nullable) {
error = true;
- Report.error (param.source_reference, "Only nullable struct elements are supported in params-array");
+ context.report.log_error (param.source_reference, "Only nullable struct elements are supported in params-array");
}
if (type.length != null) {
error = true;
- Report.error (param.source_reference, "Passing length to params-array is not supported yet");
+ context.report.log_error (param.source_reference, "Passing length to params-array is not supported yet");
}
params_array_var = new LocalVariable (type, param.name, null, param.source_reference);
body.insert_statement (0, new DeclarationStatement (params_array_var, param.source_reference));
// check whether error type is at least as accessible as the creation method
if (!error_type.is_accessible (this)) {
error = true;
- Report.error (source_reference, "error type `%s' is less accessible than creation method `%s'", error_type.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "error type `%s' is less accessible than creation method `%s'", error_type.to_string (), get_full_name ());
return false;
}
}
context.analyzer.insert_block = old_insert_block;
} else if (cl.base_class.default_construction_method == null
|| cl.base_class.default_construction_method.access == SymbolAccessibility.PRIVATE) {
- Report.error (source_reference, "unable to chain up to private base constructor");
+ context.report.log_error (source_reference, "unable to chain up to private base constructor");
} else if (cl.base_class.default_construction_method.get_required_arguments () > 0) {
- Report.error (source_reference, "unable to chain up to base constructor requiring arguments");
+ context.report.log_error (source_reference, "unable to chain up to base constructor requiring arguments");
} else {
var old_insert_block = context.analyzer.insert_block;
context.analyzer.current_symbol = body;
} else if (type_symbol is Delegate) {
expected_n_type_args = ((Delegate) type_symbol).get_type_parameters ().size;
} else if (n_type_args > 0) {
- Report.error (source_reference, "`%s' does not support type arguments", type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "`%s' does not support type arguments", type_symbol.get_full_name ());
error = true;
return false;
} else {
if ((!allow_none || n_type_args > 0) && n_type_args < expected_n_type_args) {
error = true;
- Report.error (source_reference, "too few type arguments for `%s'", type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "too few type arguments for `%s'", type_symbol.get_full_name ());
return false;
} else if ((!allow_none || n_type_args > 0) && n_type_args > expected_n_type_args) {
error = true;
- Report.error (source_reference, "too many type arguments for `%s'", type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "too many type arguments for `%s'", type_symbol.get_full_name ());
return false;
}
if (return_type.type_symbol == context.analyzer.va_list_type.type_symbol) {
error = true;
- Report.error (source_reference, "`%s' not supported as return type", return_type.type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "`%s' not supported as return type", return_type.type_symbol.get_full_name ());
return false;
}
foreach (DataType error_type in error_types) {
if (!(error_type is ErrorType)) {
error = true;
- Report.error (error_type.source_reference, "`%s' is not an error type", error_type.to_string ());
+ context.report.log_error (error_type.source_reference, "`%s' is not an error type", error_type.to_string ());
}
error_type.check (context);
// check whether error type is at least as accessible as the delegate
if (!error_type.is_accessible (this)) {
error = true;
- Report.error (source_reference, "error type `%s' is less accessible than delegate `%s'", error_type.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "error type `%s' is less accessible than delegate `%s'", error_type.to_string (), get_full_name ());
return false;
}
}
public override bool check (CodeContext context) {
if (is_called_once && !value_owned) {
- Report.warning (source_reference, "delegates with scope=\"async\" must be owned");
+ context.report.log_warning (source_reference, "delegates with scope=\"async\" must be owned");
}
if (!delegate_symbol.check (context)) {
if (!(expression.value_type is PointerType) && !(expression.value_type is ArrayType)) {
error = true;
- Report.error (source_reference, "delete operator not supported for `%s'", expression.value_type.to_string ());
+ context.report.log_error (source_reference, "delete operator not supported for `%s'", expression.value_type.to_string ());
}
return !error;
body.get_error_types (body_errors);
foreach (DataType body_error_type in body_errors) {
if (!((ErrorType) body_error_type).dynamic_error) {
- Report.warning (body_error_type.source_reference, "unhandled error `%s'", body_error_type.to_string());
+ context.report.log_warning (body_error_type.source_reference, "unhandled error `%s'", body_error_type.to_string());
}
}
}
if (container.value_type == null) {
error = true;
- Report.error (container.source_reference, "Invalid container expression");
+ context.report.log_error (container.source_reference, "Invalid container expression");
return false;
}
// signal detail access
if (get_indices ().size != 1) {
error = true;
- Report.error (source_reference, "Element access with more than one dimension is not supported for signals");
+ context.report.log_error (source_reference, "Element access with more than one dimension is not supported for signals");
return false;
}
if (detail_expr.value_type is NullType || !detail_expr.value_type.compatible (context.analyzer.string_type)) {
error = true;
- Report.error (detail_expr.source_reference, "only string details are supported");
+ context.report.log_error (detail_expr.source_reference, "only string details are supported");
return false;
}
}
if (array_type.rank < get_indices ().size) {
error = true;
- Report.error (source_reference, "%d extra indices for element access", get_indices ().size - array_type.rank);
+ context.report.log_error (source_reference, "%d extra indices for element access", get_indices ().size - array_type.rank);
} else if (array_type.rank > get_indices ().size) {
error = true;
- Report.error (source_reference, "%d missing indices for element access", array_type.rank - get_indices ().size);
+ context.report.log_error (source_reference, "%d missing indices for element access", array_type.rank - get_indices ().size);
}
} else if (pointer_type != null && !pointer_type.base_type.is_reference_type_or_type_parameter ()) {
value_type = pointer_type.base_type.copy ();
}
error = true;
- Report.error (source_reference, "The expression `%s' does not denote an array", container.value_type.to_string ());
+ context.report.log_error (source_reference, "The expression `%s' does not denote an array", container.value_type.to_string ());
return false;
}
/* check if the index is of type integer */
if (!(e.value_type is IntegerType || e.value_type is EnumValueType)) {
error = true;
- Report.error (e.source_reference, "Expression of integer type expected");
+ context.report.log_error (e.source_reference, "Expression of integer type expected");
}
}
}
context.analyzer.current_symbol = this;
if (values.size <= 0) {
- Report.error (source_reference, "Enum `%s' requires at least one value", get_full_name ());
+ context.report.log_error (source_reference, "Enum `%s' requires at least one value", get_full_name ());
error = true;
return false;
}
// check whether initializer is at least as accessible as the enum value
if (!value.is_accessible (this)) {
error = true;
- Report.error (value.source_reference, "value is less accessible than enum `%s'", parent_symbol.get_full_name ());
+ context.report.log_error (value.source_reference, "value is less accessible than enum `%s'", parent_symbol.get_full_name ());
}
}
checked = true;
if (codes.size <= 0) {
- Report.error (source_reference, "Error domain `%s' requires at least one code", get_full_name ());
+ context.report.log_error (source_reference, "Error domain `%s' requires at least one code", get_full_name ());
error = true;
return false;
}
if (external_package) {
Report.warning (m.source_reference, "Instance methods are not supported in error domains yet");
} else {
- Report.error (m.source_reference, "Instance methods are not supported in error domains yet");
+ context.report.log_error (m.source_reference, "Instance methods are not supported in error domains yet");
}
error = true;
}
}
if (inner.value_type == null) {
- Report.error (inner.source_reference, "invalid inner expression");
+ context.report.log_error (inner.source_reference, "invalid inner expression");
return false;
}
// declare the inner expression as a local variable to check for null
var inner_type = inner.value_type.copy ();
if (context.experimental_non_null && !inner_type.nullable) {
- Report.warning (inner.source_reference, "inner expression is never null");
+ context.report.log_warning (inner.source_reference, "inner expression is never null");
// make it nullable, otherwise the null check will not compile in non-null mode
inner_type.nullable = true;
}
}
if (non_null_expr.value_type == null) {
- Report.error (source_reference, "invalid null-safe expression");
+ context.report.log_error (source_reference, "invalid null-safe expression");
error = true;
return false;
}
unowned Block? parent_block = parent_stmt != null ? parent_stmt.parent_node as Block : null;
if (parent_stmt == null || parent_block == null) {
- Report.error (source_reference, "void method call not allowed here");
+ context.report.log_error (source_reference, "void method call not allowed here");
error = true;
return false;
}
// ownership can be transferred transitively
result_access.lvalue = true;
} else {
- Report.error (source_reference, "null-safe expression not supported as lvalue");
+ context.report.log_error (source_reference, "null-safe expression not supported as lvalue");
error = true;
return false;
}
error = true;
return false;
} else if (expression is Literal) {
- Report.error (source_reference, "Literal expression not allowed as statement");
+ context.report.log_error (source_reference, "Literal expression not allowed as statement");
error = true;
return false;
}
if (variable_type is VoidType) {
error = true;
- Report.error (source_reference, "'void' not supported as field type");
+ context.report.log_error (source_reference, "'void' not supported as field type");
return false;
}
if (variable_type.type_symbol == context.analyzer.va_list_type.type_symbol) {
error = true;
- Report.error (source_reference, "`%s' not supported as field type", variable_type.type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "`%s' not supported as field type", variable_type.type_symbol.get_full_name ());
return false;
}
if (get_attribute ("GtkChild") != null && variable_type.value_owned) {
- Report.warning (source_reference, "[GtkChild] fields must be declared as `unowned'");
+ context.report.log_warning (source_reference, "[GtkChild] fields must be declared as `unowned'");
variable_type.value_owned = false;
}
// check whether field type is at least as accessible as the field
if (!variable_type.is_accessible (this)) {
error = true;
- Report.error (source_reference, "field type `%s' is less accessible than field `%s'", variable_type.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "field type `%s' is less accessible than field `%s'", variable_type.to_string (), get_full_name ());
return false;
}
unowned ArrayType? variable_array_type = variable_type as ArrayType;
if (variable_array_type != null && variable_array_type.inline_allocated
&& initializer is ArrayCreationExpression && ((ArrayCreationExpression) initializer).initializer_list == null) {
- Report.warning (source_reference, "Inline allocated arrays don't require an explicit instantiation");
+ context.report.log_warning (source_reference, "Inline allocated arrays don't require an explicit instantiation");
initializer = null;
}
if (variable_array_type != null && variable_array_type.inline_allocated
&& !variable_array_type.fixed_length) {
- Report.error (source_reference, "Inline allocated array as field requires to have fixed length");
+ context.report.log_error (source_reference, "Inline allocated array as field requires to have fixed length");
}
if (initializer != null) {
if (initializer.value_type == null) {
error = true;
- Report.error (source_reference, "expression type not allowed as initializer");
+ context.report.log_error (source_reference, "expression type not allowed as initializer");
return false;
}
if (!initializer.value_type.compatible (variable_type)) {
error = true;
- Report.error (source_reference, "Cannot convert from `%s' to `%s'", initializer.value_type.to_string (), variable_type.to_string ());
+ context.report.log_error (source_reference, "Cannot convert from `%s' to `%s'", initializer.value_type.to_string (), variable_type.to_string ());
return false;
}
if (variable_array_type != null && variable_array_type.inline_allocated && !(initializer.value_type is ArrayType)) {
error = true;
- Report.error (source_reference, "only arrays are allowed as initializer for arrays with fixed length");
+ context.report.log_error (source_reference, "only arrays are allowed as initializer for arrays with fixed length");
return false;
}
if (!(variable_type is PointerType) && !variable_type.value_owned) {
/* lhs doesn't own the value */
error = true;
- Report.error (source_reference, "Invalid assignment from owned expression to unowned variable");
+ context.report.log_error (source_reference, "Invalid assignment from owned expression to unowned variable");
return false;
}
}
if (parent_symbol is Namespace && !initializer.is_constant ()) {
error = true;
- Report.error (source_reference, "Non-constant field initializers not supported in this context");
+ context.report.log_error (source_reference, "Non-constant field initializers not supported in this context");
return false;
}
if (parent_symbol is Namespace && initializer.is_constant () && initializer.is_non_null ()) {
if (variable_type.is_disposable () && variable_type.value_owned) {
error = true;
- Report.error (source_reference, "Owned namespace fields can only be initialized in a function or method");
+ context.report.log_error (source_reference, "Owned namespace fields can only be initialized in a function or method");
return false;
}
}
if (binding == MemberBinding.STATIC && parent_symbol is Class && ((Class)parent_symbol).is_compact && !initializer.is_constant ()) {
error = true;
- Report.error (source_reference, "Static fields in compact classes cannot have non-constant initializers");
+ context.report.log_error (source_reference, "Static fields in compact classes cannot have non-constant initializers");
return false;
}
if (external) {
error = true;
- Report.error (source_reference, "External fields cannot use initializers");
+ context.report.log_error (source_reference, "External fields cannot use initializers");
}
}
if (binding == MemberBinding.INSTANCE && parent_symbol is Interface) {
error = true;
- Report.error (source_reference, "Interfaces may not have instance fields");
+ context.report.log_error (source_reference, "Interfaces may not have instance fields");
return false;
}
}
if (!external_package && !hides && get_hidden_member () != null) {
- Report.warning (source_reference, "%s hides inherited field `%s'. Use the `new' keyword if hiding was intentional", get_full_name (), get_hidden_member ().get_full_name ());
+ context.report.log_warning (source_reference, "%s hides inherited field `%s'. Use the `new' keyword if hiding was intentional", get_full_name (), get_hidden_member ().get_full_name ());
}
context.analyzer.current_source_file = old_source_file;
error = true;
return false;
} else if (collection.value_type == null) {
- Report.error (collection.source_reference, "invalid collection expression");
+ context.report.log_error (collection.source_reference, "invalid collection expression");
error = true;
return false;
}
|| collection_type.compatible (context.analyzer.gslist_type) || collection_type.compatible (context.analyzer.genericarray_type))) {
if (collection_type.get_type_arguments ().size != 1) {
error = true;
- Report.error (collection.source_reference, "missing type argument for collection");
+ context.report.log_error (collection.source_reference, "missing type argument for collection");
return false;
}
var iterator_method = collection_type.get_member ("iterator") as Method;
if (iterator_method == null) {
- Report.error (collection.source_reference, "`%s' does not have an `iterator' method", collection_type.to_string ());
+ context.report.log_error (collection.source_reference, "`%s' does not have an `iterator' method", collection_type.to_string ());
error = true;
return false;
}
if (iterator_method.get_parameters ().size != 0) {
- Report.error (collection.source_reference, "`%s' must not have any parameters", iterator_method.get_full_name ());
+ context.report.log_error (collection.source_reference, "`%s' must not have any parameters", iterator_method.get_full_name ());
error = true;
return false;
}
var iterator_type = iterator_method.return_type.get_actual_type (collection_type, null, this);
if (iterator_type is VoidType) {
- Report.error (collection.source_reference, "`%s' must return an iterator", iterator_method.get_full_name ());
+ context.report.log_error (collection.source_reference, "`%s' must return an iterator", iterator_method.get_full_name ());
error = true;
return false;
}
var next_method = iterator_type.get_member ("next") as Method;
if (next_value_method != null) {
if (next_value_method.get_parameters ().size != 0) {
- Report.error (collection.source_reference, "`%s' must not have any parameters", next_value_method.get_full_name ());
+ context.report.log_error (collection.source_reference, "`%s' must not have any parameters", next_value_method.get_full_name ());
error = true;
return false;
}
var element_type = next_value_method.return_type.get_actual_type (iterator_type, null, this);
if (!element_type.nullable) {
- Report.error (collection.source_reference, "return type of `%s' must be nullable", next_value_method.get_full_name ());
+ context.report.log_error (collection.source_reference, "return type of `%s' must be nullable", next_value_method.get_full_name ());
error = true;
return false;
}
add_statement (loop);
} else if (next_method != null) {
if (next_method.get_parameters ().size != 0) {
- Report.error (collection.source_reference, "`%s' must not have any parameters", next_method.get_full_name ());
+ context.report.log_error (collection.source_reference, "`%s' must not have any parameters", next_method.get_full_name ());
error = true;
return false;
}
if (!next_method.return_type.compatible (context.analyzer.bool_type)) {
- Report.error (collection.source_reference, "`%s' must return a boolean value", next_method.get_full_name ());
+ context.report.log_error (collection.source_reference, "`%s' must return a boolean value", next_method.get_full_name ());
error = true;
return false;
}
var get_method = iterator_type.get_member ("get") as Method;
if (get_method == null) {
- Report.error (collection.source_reference, "`%s' does not have a `get' method", iterator_type.to_string ());
+ context.report.log_error (collection.source_reference, "`%s' does not have a `get' method", iterator_type.to_string ());
error = true;
return false;
}
if (get_method.get_parameters ().size != 0) {
- Report.error (collection.source_reference, "`%s' must not have any parameters", get_method.get_full_name ());
+ context.report.log_error (collection.source_reference, "`%s' must not have any parameters", get_method.get_full_name ());
error = true;
return false;
}
var element_type = get_method.return_type.get_actual_type (iterator_type, null, this);
if (element_type is VoidType) {
- Report.error (collection.source_reference, "`%s' must return an element", get_method.get_full_name ());
+ context.report.log_error (collection.source_reference, "`%s' must return an element", get_method.get_full_name ());
error = true;
return false;
}
var get_call = new MethodCall (new MemberAccess (new MemberAccess.simple ("_%s_it".printf (variable_name), source_reference), "get", source_reference), source_reference);
body.insert_statement (0, new DeclarationStatement (new LocalVariable (type_reference, variable_name, get_call, source_reference), source_reference));
} else {
- Report.error (collection.source_reference, "`%s' does not have a `next_value' or `next' method", iterator_type.to_string ());
+ context.report.log_error (collection.source_reference, "`%s' does not have a `next_value' or `next' method", iterator_type.to_string ());
error = true;
return false;
}
}
} else if (!element_type.compatible (type_reference)) {
error = true;
- Report.error (source_reference, "Foreach: Cannot convert from `%s' to `%s'", element_type.to_string (), type_reference.to_string ());
+ context.report.log_error (source_reference, "Foreach: Cannot convert from `%s' to `%s'", element_type.to_string (), type_reference.to_string ());
return false;
}
}
var arg_type = ArgumentType.from_string (id);
if (arg_type == null) {
- Report.warning (get_src (begin, old_end), "unknown argument `%s'", id);
+ scanner.source_file.context.report.log_warning (get_src (begin, old_end), "unknown argument `%s'", id);
continue;
}
// assume method is getter
merged = true;
} else {
- Report.warning (symbol.source_reference, "Field `%s' conflicts with method of the same name", get_full_name ());
+ parser.context.report.log_warning (symbol.source_reference, "Field `%s' conflicts with method of the same name", get_full_name ());
}
} else if (sym is Signal) {
node.process (parser);
}
parser.assume_parameter_names (sig, m, false);
if (m.get_parameters().size != sig.get_parameters().size) {
- Report.warning (symbol.source_reference, "Signal `%s' conflicts with method of the same name", get_full_name ());
+ parser.context.report.log_warning (symbol.source_reference, "Signal `%s' conflicts with method of the same name", get_full_name ());
}
merged = true;
} else if (sym is Method && !(sym is CreationMethod) && node != this) {
}
if (!different_invoker) {
if (attr != null) {
- Report.warning (symbol.source_reference, "Virtual method `%s' conflicts with method of the same name", get_full_name ());
+ parser.context.report.log_warning (symbol.source_reference, "Virtual method `%s' conflicts with method of the same name", get_full_name ());
}
node.merged = true;
}
} else if (m.is_class_member ()) {
- Report.warning (symbol.source_reference, "Class method `%s' conflicts with method of the same name", get_full_name ());
+ parser.context.report.log_warning (symbol.source_reference, "Class method `%s' conflicts with method of the same name", get_full_name ());
node.merged = true;
}
}
// properties take precedence
node.processed = true;
node.merged = true;
- Report.warning (symbol.source_reference, "Signal `%s' conflicts with property of the same name", get_full_name ());
+ parser.context.report.log_warning (symbol.source_reference, "Signal `%s' conflicts with property of the same name", get_full_name ());
} else if (node.symbol is Method) {
// getter in C, but not in Vala
node.merged = true;
void end_element (string name) {
while (current_token != MarkupTokenType.END_ELEMENT || reader.name != name) {
- Report.warning (get_current_src (), "expected end element of `%s'", name);
+ context.report.log_warning (get_current_src (), "expected end element of `%s'", name);
skip_element ();
}
next ();
if (name == null) {
name = default_name;
} else if (name.contains ("-")) {
- Report.warning (get_current_src (), "parameter name contains hyphen");
+ context.report.log_warning (get_current_src (), "parameter name contains hyphen");
name = name.replace ("-", "_");
}
string direction = null;
}
if (metadata.args.size == 0 && metadata.children.size == 0) {
- Report.warning (metadata.source_reference, "empty metadata");
+ context.report.log_warning (metadata.source_reference, "empty metadata");
return;
}
var arg = metadata.args[arg_type];
if (!arg.used) {
// if metadata is used and argument is not, then it's a unexpected argument
- Report.warning (arg.source_reference, "argument never used");
+ context.report.log_warning (arg.source_reference, "argument never used");
}
}
foreach (var child in metadata.children) {
if (!child.used) {
- Report.warning (child.source_reference, "metadata never used");
+ context.report.log_warning (child.source_reference, "metadata never used");
} else {
report_unused_metadata (child);
}
alias.symbol = deleg;
} else if (type_sym != null) {
- Report.warning (alias.source_reference, "alias `%s' for `%s' is not supported", alias.get_full_name (), type_sym.get_full_name ());
+ context.report.log_warning (alias.source_reference, "alias `%s' for `%s' is not supported", alias.get_full_name (), type_sym.get_full_name ());
alias.symbol = type_sym;
alias.merged = true;
}
param.direction = ParameterDirection.IN;
param.variable_type.nullable = false;
param.variable_type = new PointerType (param.variable_type);
- Report.warning (param.source_reference, "Synchronous out-parameters are not supported in async methods");
+ context.report.log_warning (param.source_reference, "Synchronous out-parameters are not supported in async methods");
}
}
if (condition.value_type == null || !condition.value_type.compatible (context.analyzer.bool_type)) {
error = true;
- Report.error (condition.source_reference, "Condition must be boolean");
+ context.report.log_error (condition.source_reference, "Condition must be boolean");
return false;
}
if (target_type == null) {
error = true;
- Report.error (source_reference, "initializer list used for unknown type");
+ context.report.log_error (source_reference, "initializer list used for unknown type");
return false;
} else if (target_type.error) {
error = true;
while (field == null) {
if (!field_it.next ()) {
error = true;
- Report.error (e.source_reference, "too many expressions in initializer list for `%s'", target_type.to_string ());
+ context.report.log_error (e.source_reference, "too many expressions in initializer list for `%s'", target_type.to_string ());
return false;
}
field = field_it.get ();
}
} else {
error = true;
- Report.error (source_reference, "initializer list used for `%s', which is neither array nor struct", target_type.to_string ());
+ context.report.log_error (source_reference, "initializer list used for `%s', which is neither array nor struct", target_type.to_string ());
return false;
}
foreach (Expression e in get_initializers ()) {
if (e.value_type == null) {
error = true;
- Report.error (e.source_reference, "expression type not allowed as initializer");
+ context.report.log_error (e.source_reference, "expression type not allowed as initializer");
continue;
}
} else if (!e.value_type.compatible (e.target_type)) {
error = true;
e.error = true;
- Report.error (e.source_reference, "Expected initializer of type `%s' but got `%s'", e.target_type.to_string (), e.value_type.to_string ());
+ context.report.log_error (e.source_reference, "Expected initializer of type `%s' but got `%s'", e.target_type.to_string (), e.value_type.to_string ());
}
}
// check whether prerequisite is at least as accessible as the interface
if (!prerequisite_reference.is_accessible (this)) {
error = true;
- Report.error (source_reference, "prerequisite `%s' is less accessible than interface `%s'", prerequisite_reference.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "prerequisite `%s' is less accessible than interface `%s'", prerequisite_reference.to_string (), get_full_name ());
return false;
}
}
foreach (DataType prereq in get_prerequisites ()) {
if (!(prereq is ObjectType)) {
error = true;
- Report.error (source_reference, "Prerequisite `%s' of interface `%s' is not a class or interface", prereq.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "Prerequisite `%s' of interface `%s' is not a class or interface", prereq.to_string (), get_full_name ());
return false;
}
if (prereq.type_symbol is Class) {
if (prereq_class != null) {
error = true;
- Report.error (source_reference, "%s: Interfaces cannot have multiple instantiable prerequisites (`%s' and `%s')", get_full_name (), prereq.type_symbol.get_full_name (), prereq_class.get_full_name ());
+ context.report.log_error (source_reference, "%s: Interfaces cannot have multiple instantiable prerequisites (`%s' and `%s')", get_full_name (), prereq.type_symbol.get_full_name (), prereq_class.get_full_name ());
return false;
}
foreach (Symbol sym in virtuals) {
int ordering = sym.get_attribute_integer ("CCode", "ordering", -1);
if (ordering < -1) {
- Report.error (sym.source_reference, "%s: Invalid ordering", sym.get_full_name ());
+ context.report.log_error (sym.source_reference, "%s: Invalid ordering", sym.get_full_name ());
// Mark state as invalid
error = true;
ordered_seen = true;
}
bool ordered = ordering != -1;
if (ordered && unordered_seen && !ordered_seen) {
- Report.error (sym.source_reference, "%s: Cannot mix ordered and unordered virtuals", sym.get_full_name ());
+ context.report.log_error (sym.source_reference, "%s: Cannot mix ordered and unordered virtuals", sym.get_full_name ());
error = true;
}
ordered_seen = ordered_seen || ordered;
if (!ordered && !unordered_seen && ordered_seen) {
- Report.error (sym.source_reference, "%s: Cannot mix ordered and unordered virtuals", sym.get_full_name ());
+ context.report.log_error (sym.source_reference, "%s: Cannot mix ordered and unordered virtuals", sym.get_full_name ());
error = true;
}
unordered_seen = unordered_seen || !ordered;
if (ordered) {
Symbol? prev = positions[ordering];
if (prev != null) {
- Report.error (sym.source_reference, "%s: Duplicate ordering (previous virtual with the same position is %s)", sym.get_full_name (), prev.name);
+ context.report.log_error (sym.source_reference, "%s: Duplicate ordering (previous virtual with the same position is %s)", sym.get_full_name (), prev.name);
error = true;
}
positions[ordering] = sym;
for (int i = 0; i < virtuals.size; i++) {
Symbol? sym = positions[i];
if (sym == null) {
- Report.error (source_reference, "%s: Gap in ordering in position %d", get_full_name (), i);
+ context.report.log_error (source_reference, "%s: Gap in ordering in position %d", get_full_name (), i);
error = true;
}
if (!error) {
if (!(target_type is DelegateType)) {
error = true;
if (target_type != null) {
- Report.error (source_reference, "Cannot convert lambda expression to `%s'", target_type.to_string ());
+ context.report.log_error (source_reference, "Cannot convert lambda expression to `%s'", target_type.to_string ());
} else {
- Report.error (source_reference, "lambda expression not allowed in this context");
+ context.report.log_error (source_reference, "lambda expression not allowed in this context");
}
return false;
}
if (lambda_param.direction != cb_param.direction) {
error = true;
- Report.error (lambda_param.source_reference, "direction of parameter `%s' is incompatible with the target delegate", lambda_param.name);
+ context.report.log_error (lambda_param.source_reference, "direction of parameter `%s' is incompatible with the target delegate", lambda_param.name);
}
lambda_param.variable_type = cb_param.variable_type.get_actual_type (target_type, null, this);
if (lambda_param_it.next ()) {
/* lambda expressions may not expect more parameters */
error = true;
- Report.error (source_reference, "lambda expression: too many parameters");
+ context.report.log_error (source_reference, "lambda expression: too many parameters");
return false;
}
if (!(variable_type is VarType)) {
if (variable_type is VoidType) {
error = true;
- Report.error (source_reference, "'void' not supported as variable type");
+ context.report.log_error (source_reference, "'void' not supported as variable type");
} else if (!variable_type.check (context)) {
error = true;
}
error = true;
} else if (initializer.value_type is VoidType) {
error = true;
- Report.error (initializer.source_reference, "'void' not supported as initializer type");
+ context.report.log_error (initializer.source_reference, "'void' not supported as initializer type");
}
}
if (initializer == null) {
error = true;
- Report.error (source_reference, "var declaration not allowed without initializer");
+ context.report.log_error (source_reference, "var declaration not allowed without initializer");
return false;
}
if (initializer.value_type == null) {
error = true;
- Report.error (source_reference, "var declaration not allowed with non-typed initializer");
+ context.report.log_error (source_reference, "var declaration not allowed with non-typed initializer");
return false;
}
if (initializer.value_type is FieldPrototype || initializer.value_type is PropertyPrototype) {
error = true;
- Report.error (initializer.source_reference, "Access to instance member `%s' denied", initializer.symbol_reference.get_full_name ());
+ context.report.log_error (initializer.source_reference, "Access to instance member `%s' denied", initializer.symbol_reference.get_full_name ());
return false;
}
if (variable_array_type != null && variable_array_type.inline_allocated
&& variable_array_type.length == null && !(initializer is ArrayCreationExpression)) {
error = true;
- Report.error (source_reference, "Inline allocated array requires either a given length or an initializer");
+ context.report.log_error (source_reference, "Inline allocated array requires either a given length or an initializer");
}
if (initializer != null && !initializer.error) {
if (initializer.value_type is MethodType) {
if (!(initializer is MemberAccess) && !(initializer is LambdaExpression)) {
error = true;
- Report.error (source_reference, "expression type not allowed as initializer");
+ context.report.log_error (source_reference, "expression type not allowed as initializer");
return false;
}
unowned Method m = (Method) initializer.symbol_reference;
unowned Delegate cb = ((DelegateType) variable_type).delegate_symbol;
error = true;
- Report.error (source_reference, "Declaration of method `%s' is not compatible with delegate `%s'", m.get_full_name (), cb.get_full_name ());
+ context.report.log_error (source_reference, "Declaration of method `%s' is not compatible with delegate `%s'", m.get_full_name (), cb.get_full_name ());
return false;
}
} else {
error = true;
- Report.error (source_reference, "expression type not allowed as initializer");
+ context.report.log_error (source_reference, "expression type not allowed as initializer");
return false;
}
} else if (initializer.value_type == null) {
error = true;
- Report.error (source_reference, "expression type not allowed as initializer");
+ context.report.log_error (source_reference, "expression type not allowed as initializer");
return false;
}
if (!initializer.value_type.compatible (variable_type)) {
error = true;
- Report.error (source_reference, "Assignment: Cannot convert from `%s' to `%s'", initializer.value_type.to_string (), variable_type.to_string ());
+ context.report.log_error (source_reference, "Assignment: Cannot convert from `%s' to `%s'", initializer.value_type.to_string (), variable_type.to_string ());
return false;
} else if (variable_type is EnumValueType && initializer.value_type is IntegerType
&& (!(initializer is IntegerLiteral) || ((IntegerLiteral) initializer).value != "0")) {
if (variable_array_type != null && variable_array_type.inline_allocated && initializer.value_type is ArrayType == false) {
error = true;
- Report.error (source_reference, "only arrays are allowed as initializer for arrays with fixed length");
+ context.report.log_error (source_reference, "only arrays are allowed as initializer for arrays with fixed length");
return false;
}
if (!(variable_type is PointerType) && !variable_type.value_owned) {
/* lhs doesn't own the value */
error = true;
- Report.error (source_reference, "Invalid assignment from owned expression to unowned variable");
+ context.report.log_error (source_reference, "Invalid assignment from owned expression to unowned variable");
return false;
}
}
if (member_name == "this") {
if (!context.analyzer.is_in_instance_method ()) {
error = true;
- Report.error (source_reference, "This access invalid outside of instance methods");
+ context.report.log_error (source_reference, "This access invalid outside of instance methods");
return false;
}
}
if (local_sym != null) {
if (symbol_reference != null && symbol_reference != local_sym) {
error = true;
- Report.error (source_reference, "`%s' is an ambiguous reference between `%s' and `%s'", member_name, symbol_reference.get_full_name (), local_sym.get_full_name ());
+ context.report.log_error (source_reference, "`%s' is an ambiguous reference between `%s' and `%s'", member_name, symbol_reference.get_full_name (), local_sym.get_full_name ());
return false;
}
unowned MemberAccess ma = (MemberAccess) inner;
if (ma.prototype_access) {
error = true;
- Report.error (source_reference, "Access to instance member `%s' denied", inner.symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Access to instance member `%s' denied", inner.symbol_reference.get_full_name ());
return false;
}
}
if (arg == null || !arg.check (context) || !(arg.symbol_reference is Method)) {
error = true;
if (s.handler is LambdaExpression) {
- Report.error (s.handler.source_reference, "Lambdas are not allowed for dynamic signals");
+ context.report.log_error (s.handler.source_reference, "Lambdas are not allowed for dynamic signals");
} else {
- Report.error (s.handler.source_reference, "Cannot infer call signature for dynamic signal `%s' from given expression", s.get_full_name ());
+ context.report.log_error (s.handler.source_reference, "Cannot infer call signature for dynamic signal `%s' from given expression", s.get_full_name ());
}
}
}
symbol_reference = s;
} else if (ma.member_name == "disconnect") {
error = true;
- Report.error (ma.source_reference, "Use SignalHandler.disconnect() to disconnect from dynamic signal");
+ context.report.log_error (ma.source_reference, "Use SignalHandler.disconnect() to disconnect from dynamic signal");
}
}
if (symbol_reference == null) {
// require the real type with its original value_owned attritubte
var inner_type = context.analyzer.get_value_type_for_symbol (inner.symbol_reference, true) as ArrayType;
if (inner_type != null && inner_type.inline_allocated) {
- Report.error (source_reference, "`resize' is not supported for arrays with fixed length");
+ context.report.log_error (source_reference, "`resize' is not supported for arrays with fixed length");
error = true;
} else if (inner_type != null && !inner_type.value_owned) {
- Report.error (source_reference, "`resize' is not allowed for unowned array references");
+ context.report.log_error (source_reference, "`resize' is not allowed for unowned array references");
error = true;
}
} else if (inner.symbol_reference is Constant) {
// disallow resize() for const array
- Report.error (source_reference, "`resize' is not allowed for constant arrays");
+ context.report.log_error (source_reference, "`resize' is not allowed for constant arrays");
error = true;
}
}
visited_types_string += " or `%s'".printf (type.to_string ());
}
- Report.error (source_reference, "The name `%s' does not exist in the context of `%s'%s%s", member_name, base_type_name, base_type_package, visited_types_string);
+ context.report.log_error (source_reference, "The name `%s' does not exist in the context of `%s'%s%s", member_name, base_type_name, base_type_package, visited_types_string);
value_type = new InvalidType ();
return false;
} else if (symbol_reference.error) {
symbol_reference = sig.emitter;
} else {
error = true;
- Report.error (source_reference, "Signal `%s' requires emitter in this context", symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Signal `%s' requires emitter in this context", symbol_reference.get_full_name ());
return false;
}
}
if (local.variable_type.type_symbol == context.analyzer.va_list_type.type_symbol) {
error = true;
- Report.error (source_reference, "Capturing `va_list' variable `%s' is not allowed", local.get_full_name ());
+ context.report.log_error (source_reference, "Capturing `va_list' variable `%s' is not allowed", local.get_full_name ());
}
}
} else if (member is Parameter) {
if (param.direction != ParameterDirection.IN) {
error = true;
- Report.error (source_reference, "Cannot capture reference or output parameter `%s'", param.get_full_name ());
+ context.report.log_error (source_reference, "Cannot capture reference or output parameter `%s'", param.get_full_name ());
}
if (param.variable_type.type_symbol == context.analyzer.va_list_type.type_symbol) {
error = true;
- Report.error (source_reference, "Capturing `va_list' parameter `%s' is not allowed", param.get_full_name ());
+ context.report.log_error (source_reference, "Capturing `va_list' parameter `%s' is not allowed", param.get_full_name ());
}
} else {
unowned PropertyAccessor? acc = param.parent_symbol.parent_symbol as PropertyAccessor;
unowned Block? block = c.parent_symbol as Block;
if (block != null && SemanticAnalyzer.find_parent_method_or_property_accessor (block) != context.analyzer.current_method_or_property_accessor) {
error = true;
- Report.error (source_reference, "internal error: accessing local constants of outer methods is not supported yet");
+ context.report.log_error (source_reference, "internal error: accessing local constants of outer methods is not supported yet");
return false;
}
} else if (member is Method) {
}
if (!is_valid_access) {
error = true;
- Report.error (source_reference, "Access to async callback `%s' not allowed in this context", m.get_full_name ());
+ context.report.log_error (source_reference, "Access to async callback `%s' not allowed in this context", m.get_full_name ());
return false;
}
if (lvalue) {
if (prop.set_accessor == null) {
error = true;
- Report.error (source_reference, "Property `%s' is read-only", prop.get_full_name ());
+ context.report.log_error (source_reference, "Property `%s' is read-only", prop.get_full_name ());
return false;
} else if (!prop.set_accessor.writable && prop.set_accessor.construction) {
if (context.analyzer.find_current_method () is CreationMethod) {
error = true;
- Report.error (source_reference, "Cannot assign to construct-only properties, use Object (property: value) constructor chain up");
+ context.report.log_error (source_reference, "Cannot assign to construct-only properties, use Object (property: value) constructor chain up");
return false;
} else if (context.analyzer.is_in_constructor ()) {
if (!context.analyzer.current_type_symbol.is_subtype_of ((TypeSymbol) prop.parent_symbol)) {
error = true;
- Report.error (source_reference, "Cannot assign to construct-only property `%s' in `construct' of `%s'", prop.get_full_name (), context.analyzer.current_type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "Cannot assign to construct-only property `%s' in `construct' of `%s'", prop.get_full_name (), context.analyzer.current_type_symbol.get_full_name ());
return false;
}
} else {
error = true;
- Report.error (source_reference, "Cannot assign to construct-only property in this context");
+ context.report.log_error (source_reference, "Cannot assign to construct-only property in this context");
return false;
}
}
} else {
if (prop.get_accessor == null) {
error = true;
- Report.error (source_reference, "Property `%s' is write-only", prop.get_full_name ());
+ context.report.log_error (source_reference, "Property `%s' is write-only", prop.get_full_name ());
return false;
}
if (prop.access == SymbolAccessibility.PUBLIC) {
if (!in_subtype) {
error = true;
- Report.error (source_reference, "Access to protected member `%s' denied", member.get_full_name ());
+ context.report.log_error (source_reference, "Access to protected member `%s' denied", member.get_full_name ());
return false;
}
} else if (access == SymbolAccessibility.PRIVATE) {
if (!in_target_type) {
error = true;
- Report.error (source_reference, "Access to private member `%s' denied", member.get_full_name ());
+ context.report.log_error (source_reference, "Access to private member `%s' denied", member.get_full_name ());
return false;
}
}
if (object_type != null && object_type.object_type_symbol.has_type_parameters ()
&& !instance_type.has_type_arguments ()) {
error = true;
- Report.error (inner.source_reference, "missing generic type arguments");
+ context.report.log_error (inner.source_reference, "missing generic type arguments");
return false;
}
}
if (context.experimental_non_null && instance && inner.value_type.nullable &&
!(inner.value_type is PointerType) && !(inner.value_type is GenericType) &&
!(inner.value_type is ArrayType)) {
- Report.error (source_reference, "Access to instance member `%s' from nullable reference denied", symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Access to instance member `%s' from nullable reference denied", symbol_reference.get_full_name ());
}
unowned Method? m = symbol_reference as Method;
if (symbol_reference is ArrayLengthField) {
if (inner.value_type is ArrayType && ((ArrayType) inner.value_type).rank > 1 && !(parent_node is ElementAccess)) {
- Report.error (source_reference, "unsupported use of length field of multi-dimensional array");
+ context.report.log_error (source_reference, "unsupported use of length field of multi-dimensional array");
error = true;
}
} else if (symbol_reference is DelegateTargetField) {
if (!((DelegateType) inner.value_type).delegate_symbol.has_target) {
- Report.error (source_reference, "unsupported use of target field of delegate without target");
+ context.report.log_error (source_reference, "unsupported use of target field of delegate without target");
error = true;
}
} else if (symbol_reference is DelegateDestroyField) {
if (!((DelegateType) inner.value_type).delegate_symbol.has_target) {
- Report.error (source_reference, "unsupported use of destroy field of delegate without target");
+ context.report.log_error (source_reference, "unsupported use of destroy field of delegate without target");
error = true;
}
}
unowned ObjectCreationExpression? oce = parent_node as ObjectCreationExpression;
if (oce == null) {
error = true;
- Report.error (source_reference, "internal: Invalid member initializer");
+ context.report.log_error (source_reference, "internal: Invalid member initializer");
return false;
}
symbol_reference = SemanticAnalyzer.symbol_lookup_inherited (type.type_symbol, name);
if (!(symbol_reference is Field || symbol_reference is Property)) {
error = true;
- Report.error (source_reference, "Invalid member `%s' in `%s'", name, type.type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "Invalid member `%s' in `%s'", name, type.type_symbol.get_full_name ());
return false;
}
if (symbol_reference.access != SymbolAccessibility.PUBLIC) {
error = true;
- Report.error (source_reference, "Access to private member `%s' denied", symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Access to private member `%s' denied", symbol_reference.get_full_name ());
return false;
}
DataType member_type = null;
member_type = prop.property_type;
if (prop.set_accessor == null || !prop.set_accessor.writable) {
error = true;
- Report.error (source_reference, "Property `%s' is read-only", prop.get_full_name ());
+ context.report.log_error (source_reference, "Property `%s' is read-only", prop.get_full_name ());
return false;
}
}
if (initializer.value_type == null || !initializer.value_type.compatible (initializer.target_type)) {
error = true;
- Report.error (source_reference, "Invalid type for member `%s'", name);
+ context.report.log_error (source_reference, "Invalid type for member `%s'", name);
return false;
}
unowned Class cl = (Class) parent_symbol;
if (cl.is_compact && cl.base_class != null) {
error = true;
- Report.error (source_reference, "Abstract and virtual methods may not be declared in derived compact classes");
+ context.report.log_error (source_reference, "Abstract and virtual methods may not be declared in derived compact classes");
return false;
}
if (cl.is_opaque) {
error = true;
- Report.error (source_reference, "Abstract and virtual methods may not be declared in opaque compact classes");
+ context.report.log_error (source_reference, "Abstract and virtual methods may not be declared in opaque compact classes");
return false;
}
}
if (is_variadic () && (is_abstract || is_virtual)) {
error = true;
- Report.error (source_reference, "Abstract and virtual methods may not be variadic. Use a `va_list' parameter instead of `...' or params-array.");
+ context.report.log_error (source_reference, "Abstract and virtual methods may not be variadic. Use a `va_list' parameter instead of `...' or params-array.");
return false;
}
if (get_attribute ("NoWrapper") != null && !(is_abstract || is_virtual)) {
error = true;
- Report.error (source_reference, "[NoWrapper] methods must be declared abstract or virtual");
+ context.report.log_error (source_reference, "[NoWrapper] methods must be declared abstract or virtual");
return false;
}
unowned Class cl = (Class) parent_symbol;
if (!cl.is_abstract) {
error = true;
- Report.error (source_reference, "Abstract methods may not be declared in non-abstract classes");
+ context.report.log_error (source_reference, "Abstract methods may not be declared in non-abstract classes");
return false;
}
} else if (!(parent_symbol is Interface)) {
error = true;
- Report.error (source_reference, "Abstract methods may not be declared outside of classes and interfaces");
+ context.report.log_error (source_reference, "Abstract methods may not be declared outside of classes and interfaces");
return false;
}
} else if (is_virtual) {
if (!(parent_symbol is Class) && !(parent_symbol is Interface)) {
error = true;
- Report.error (source_reference, "Virtual methods may not be declared outside of classes and interfaces");
+ context.report.log_error (source_reference, "Virtual methods may not be declared outside of classes and interfaces");
return false;
}
} else if (overrides) {
if (!(parent_symbol is Class)) {
error = true;
- Report.error (source_reference, "Methods may not be overridden outside of classes");
+ context.report.log_error (source_reference, "Methods may not be overridden outside of classes");
return false;
}
} else if (access == SymbolAccessibility.PROTECTED) {
if (!(parent_symbol is Class) && !(parent_symbol is Interface)) {
error = true;
- Report.error (source_reference, "Protected methods may not be declared outside of classes and interfaces");
+ context.report.log_error (source_reference, "Protected methods may not be declared outside of classes and interfaces");
return false;
}
}
if (is_abstract && body != null) {
error = true;
- Report.error (source_reference, "Abstract methods cannot have bodies");
+ context.report.log_error (source_reference, "Abstract methods cannot have bodies");
} else if ((is_abstract || is_virtual) && is_extern) {
error = true;
- Report.error (source_reference, "Extern methods cannot be abstract or virtual");
+ context.report.log_error (source_reference, "Extern methods cannot be abstract or virtual");
} else if (is_extern && body != null) {
error = true;
- Report.error (source_reference, "Extern methods cannot have bodies");
+ context.report.log_error (source_reference, "Extern methods cannot have bodies");
} else if (!is_abstract && !external && source_type == SourceFileType.SOURCE && body == null) {
error = true;
- Report.error (source_reference, "Non-abstract, non-extern methods must have bodies");
+ context.report.log_error (source_reference, "Non-abstract, non-extern methods must have bodies");
}
if (coroutine && !external_package && !context.has_package ("gio-2.0")) {
error = true;
- Report.error (source_reference, "gio-2.0 package required for async methods");
+ context.report.log_error (source_reference, "gio-2.0 package required for async methods");
return false;
}
if (return_type.type_symbol == context.analyzer.va_list_type.type_symbol) {
error = true;
- Report.error (source_reference, "`%s' not supported as return type", return_type.type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "`%s' not supported as return type", return_type.type_symbol.get_full_name ());
return false;
}
if (parameters.size == 1 && parameters[0].ellipsis && body != null && binding != MemberBinding.INSTANCE) {
// accept just `...' for external methods and instance methods
error = true;
- Report.error (parameters[0].source_reference, "Named parameter required before `...'");
+ context.report.log_error (parameters[0].source_reference, "Named parameter required before `...'");
}
if (get_attribute ("Print") != null && (parameters.size != 1 || parameters[0].variable_type.type_symbol != context.analyzer.string_type.type_symbol)) {
error = true;
- Report.error (source_reference, "[Print] methods must have exactly one parameter of type `string'");
+ context.report.log_error (source_reference, "[Print] methods must have exactly one parameter of type `string'");
}
var optional_param = false;
}
if (coroutine && param.direction == ParameterDirection.REF) {
error = true;
- Report.error (param.source_reference, "Reference parameters are not supported for async methods");
+ context.report.log_error (param.source_reference, "Reference parameters are not supported for async methods");
}
if (!external_package && coroutine && (param.ellipsis || param.params_array || param.variable_type.type_symbol == context.analyzer.va_list_type.type_symbol)) {
error = true;
- Report.error (param.source_reference, "Variadic parameters are not supported for async methods");
+ context.report.log_error (param.source_reference, "Variadic parameters are not supported for async methods");
return false;
}
// TODO: begin and end parameters must be checked separately for coroutines
// Disallow parameter after params array or ellipsis
if (params_array_param) {
- Report.error (param.source_reference, "parameter follows params-array parameter");
+ context.report.log_error (param.source_reference, "parameter follows params-array parameter");
} else if (param.params_array) {
params_array_param = true;
}
if (ellipsis_param) {
- Report.error (param.source_reference, "parameter follows ellipsis parameter");
+ context.report.log_error (param.source_reference, "parameter follows ellipsis parameter");
} else if (param.ellipsis) {
ellipsis_param = true;
}
if (param.params_array && body != null) {
if (params_array_var != null) {
error = true;
- Report.error (param.source_reference, "Only one params-array parameter is allowed");
+ context.report.log_error (param.source_reference, "Only one params-array parameter is allowed");
continue;
}
if (!context.experimental) {
type.value_owned = true;
if (type.element_type.is_real_struct_type () && !type.element_type.nullable) {
error = true;
- Report.error (param.source_reference, "Only nullable struct elements are supported in params-array");
+ context.report.log_error (param.source_reference, "Only nullable struct elements are supported in params-array");
}
if (type.length != null) {
error = true;
- Report.error (param.source_reference, "Passing length to params-array is not supported yet");
+ context.report.log_error (param.source_reference, "Passing length to params-array is not supported yet");
}
params_array_var = new LocalVariable (type, param.name, null, param.source_reference);
body.insert_statement (0, new DeclarationStatement (params_array_var, param.source_reference));
requires_pointer = true;
} else if (requires_pointer) {
error = true;
- Report.error (param.source_reference, "Synchronous out-parameters are not supported in async methods");
+ context.report.log_error (param.source_reference, "Synchronous out-parameters are not supported in async methods");
}
}
}
foreach (DataType error_type in error_types) {
if (!(error_type is ErrorType)) {
error = true;
- Report.error (error_type.source_reference, "`%s' is not an error type", error_type.to_string ());
+ context.report.log_error (error_type.source_reference, "`%s' is not an error type", error_type.to_string ());
}
error_type.check (context);
// check whether error type is at least as accessible as the method
if (!error_type.is_accessible (this)) {
error = true;
- Report.error (source_reference, "error type `%s' is less accessible than method `%s'", error_type.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "error type `%s' is less accessible than method `%s'", error_type.to_string (), get_full_name ());
return false;
}
}
Report.warning (source_reference, "`override' not required to implement `abstract' interface method `%s'", base_interface_method.get_full_name ());
overrides = false;
} else if (overrides && base_method == null && base_interface_method == null) {
- Report.error (source_reference, "`%s': no suitable method found to override", get_full_name ());
+ context.report.log_error (source_reference, "`%s': no suitable method found to override", get_full_name ());
} else if ((is_abstract || is_virtual || overrides) && access == SymbolAccessibility.PRIVATE) {
error = true;
- Report.error (source_reference, "Private member `%s' cannot be marked as override, virtual, or abstract", get_full_name ());
+ context.report.log_error (source_reference, "Private member `%s' cannot be marked as override, virtual, or abstract", get_full_name ());
return false;
}
m.checked = true;
m.error = true;
error = true;
- Report.error (source_reference, "`%s' already contains an implementation for `%s'", cl.get_full_name (), base_interface_method.get_full_name ());
+ context.report.log_error (source_reference, "`%s' already contains an implementation for `%s'", cl.get_full_name (), base_interface_method.get_full_name ());
Report.notice (m.source_reference, "previous implementation of `%s' was here", base_interface_method.get_full_name ());
return false;
}
// check whether return type is at least as accessible as the method
if (!return_type.is_accessible (this)) {
error = true;
- Report.error (source_reference, "return type `%s' is less accessible than method `%s'", return_type.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "return type `%s' is less accessible than method `%s'", return_type.to_string (), get_full_name ());
return false;
}
if (!precondition.value_type.compatible (context.analyzer.bool_type)) {
error = true;
- Report.error (precondition.source_reference, "Precondition must be boolean");
+ context.report.log_error (precondition.source_reference, "Precondition must be boolean");
return false;
}
}
if (!postcondition.value_type.compatible (context.analyzer.bool_type)) {
error = true;
- Report.error (postcondition.source_reference, "Postcondition must be boolean");
+ context.report.log_error (postcondition.source_reference, "Postcondition must be boolean");
return false;
}
}
if (is_possible_entry_point (context)) {
if (context.entry_point != null) {
error = true;
- Report.error (source_reference, "program already has an entry point `%s'", context.entry_point.get_full_name ());
+ context.report.log_error (source_reference, "program already has an entry point `%s'", context.entry_point.get_full_name ());
return false;
}
entry_point = true;
if (tree_can_fail) {
error = true;
- Report.error (source_reference, "\"main\" method cannot throw errors");
+ context.report.log_error (source_reference, "\"main\" method cannot throw errors");
}
if (is_inline) {
error = true;
- Report.error (source_reference, "\"main\" method cannot be inline");
+ context.report.log_error (source_reference, "\"main\" method cannot be inline");
}
if (coroutine) {
error = true;
- Report.error (source_reference, "\"main\" method cannot be async");
+ context.report.log_error (source_reference, "\"main\" method cannot be async");
}
}
unowned MemberAccess ma = (MemberAccess) call;
if (ma.prototype_access) {
error = true;
- Report.error (source_reference, "Access to instance member `%s' denied", call.symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Access to instance member `%s' denied", call.symbol_reference.get_full_name ());
return false;
}
unowned CreationMethod? cm = context.analyzer.find_current_method () as CreationMethod;
if (cm == null) {
error = true;
- Report.error (source_reference, "invocation not supported in this context");
+ context.report.log_error (source_reference, "invocation not supported in this context");
return false;
} else if (cm.chain_up) {
error = true;
- Report.error (source_reference, "Multiple constructor calls in the same constructor are not permitted");
+ context.report.log_error (source_reference, "Multiple constructor calls in the same constructor are not permitted");
return false;
}
cm.chain_up = true;
base_cm = cl.default_construction_method;
if (base_cm == null) {
error = true;
- Report.error (source_reference, "chain up to `%s' not supported", cl.get_full_name ());
+ context.report.log_error (source_reference, "chain up to `%s' not supported", cl.get_full_name ());
return false;
} else if (!base_cm.has_construct_function) {
error = true;
- Report.error (source_reference, "chain up to `%s' not supported", base_cm.get_full_name ());
+ context.report.log_error (source_reference, "chain up to `%s' not supported", base_cm.get_full_name ());
return false;
}
} else if (call.symbol_reference is CreationMethod && call.symbol_reference.parent_symbol is Class) {
base_cm = (CreationMethod) call.symbol_reference;
if (!base_cm.has_construct_function) {
error = true;
- Report.error (source_reference, "chain up to `%s' not supported", base_cm.get_full_name ());
+ context.report.log_error (source_reference, "chain up to `%s' not supported", base_cm.get_full_name ());
return false;
}
} else if (gobject_chainup) {
unowned Class? cl = cm.parent_symbol as Class;
if (cl == null || !cl.is_subtype_of (context.analyzer.object_type)) {
error = true;
- Report.error (source_reference, "chain up to `GLib.Object' not supported");
+ context.report.log_error (source_reference, "chain up to `GLib.Object' not supported");
return false;
}
call.value_type = new ObjectType (context.analyzer.object_type, source_reference);
unowned Struct? st = call.symbol_reference as Struct;
if (st != null && st.default_construction_method == null && (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ())) {
error = true;
- Report.error (source_reference, "invocation not supported in this context");
+ context.report.log_error (source_reference, "invocation not supported in this context");
return false;
}
return true;
} else if (!is_chainup && call is MemberAccess && call.symbol_reference is CreationMethod) {
error = true;
- Report.error (source_reference, "use `new' operator to create new objects");
+ context.report.log_error (source_reference, "use `new' operator to create new objects");
return false;
}
if (!is_chainup && mtype is ObjectType) {
// prevent funny stuff like (new Object ()) ()
error = true;
- Report.error (source_reference, "invocation not supported in this context");
+ context.report.log_error (source_reference, "invocation not supported in this context");
return false;
} else if (mtype != null && mtype.is_invokable ()) {
// call ok, expression is invokable
} else if (call.symbol_reference is Class) {
error = true;
- Report.error (source_reference, "use `new' operator to create new objects");
+ context.report.log_error (source_reference, "use `new' operator to create new objects");
return false;
} else {
error = true;
- Report.error (source_reference, "invocation not supported in this context");
+ context.report.log_error (source_reference, "invocation not supported in this context");
return false;
}
}
} else if (ma.member_name == "begin" || ma.member_name == "end") {
error = true;
- Report.error (ma.source_reference, "use of `%s' not allowed in yield statement", ma.member_name);
+ context.report.log_error (ma.source_reference, "use of `%s' not allowed in yield statement", ma.member_name);
}
}
int n_type_args = ma.get_type_arguments ().size;
if (n_type_args > 0 && n_type_args < n_type_params) {
error = true;
- Report.error (ma.source_reference, "too few type arguments");
+ context.report.log_error (ma.source_reference, "too few type arguments");
return false;
} else if (n_type_args > 0 && n_type_args > n_type_params) {
error = true;
- Report.error (ma.source_reference, "too many type arguments");
+ context.report.log_error (ma.source_reference, "too many type arguments");
return false;
}
}
// A void method invocation can be in the initializer or
// iterator of a for statement
error = true;
- Report.error (source_reference, "invocation of void method not allowed as expression");
+ context.report.log_error (source_reference, "invocation of void method not allowed as expression");
return false;
}
}
if (is_yield_expression) {
if (!(mtype is MethodType) || !((MethodType) mtype).method_symbol.coroutine) {
error = true;
- Report.error (source_reference, "yield expression requires async method");
+ context.report.log_error (source_reference, "yield expression requires async method");
}
if (context.analyzer.current_method == null || !context.analyzer.current_method.coroutine) {
error = true;
- Report.error (source_reference, "yield expression not available outside async method");
+ context.report.log_error (source_reference, "yield expression not available outside async method");
}
}
unowned Property? prop = inner.symbol_reference as Property;
if (prop != null && (prop.set_accessor == null || !prop.set_accessor.writable)) {
error = true;
- Report.error (inner.source_reference, "Property `%s' is read-only", prop.get_full_name ());
+ context.report.log_error (inner.source_reference, "Property `%s' is read-only", prop.get_full_name ());
}
}
// avoid passing possible null to ref_sink_function without checking
if (sig != null && m.name == "disconnect") {
if (!argument_list.is_empty && argument_list[0] is LambdaExpression) {
error = true;
- Report.error (source_reference, "Cannot disconnect lambda expression from signal");
+ context.report.log_error (source_reference, "Cannot disconnect lambda expression from signal");
return false;
}
}
if (type_arg == null) {
error = true;
- Report.error (ma.source_reference, "cannot infer generic type argument for type parameter `%s'", type_param.get_full_name ());
+ context.report.log_error (ma.source_reference, "cannot infer generic type argument for type parameter `%s'", type_param.get_full_name ());
return false;
}
} else if (!(context.analyzer.current_symbol is Block)) {
// can't handle errors in field initializers
error = true;
- Report.error (source_reference, "Field initializers must not throw errors");
+ context.report.log_error (source_reference, "Field initializers must not throw errors");
} else {
// store parent_node as we need to replace the expression in the old parent node later on
var old_parent_node = parent_node;
foreach (Field f in fields) {
if (f.binding == MemberBinding.INSTANCE) {
- Report.error (f.source_reference, "instance fields are not allowed outside of data types");
+ context.report.log_error (f.source_reference, "instance fields are not allowed outside of data types");
f.error = true;
error = true;
} else if (f.binding == MemberBinding.CLASS) {
- Report.error (f.source_reference, "class fields are not allowed outside of classes");
+ context.report.log_error (f.source_reference, "class fields are not allowed outside of classes");
f.error = true;
error = true;
}
foreach (Method m in methods) {
if (m is CreationMethod) {
- Report.error (m.source_reference, "construction methods may only be declared within classes and structs");
+ context.report.log_error (m.source_reference, "construction methods may only be declared within classes and structs");
m.error = true;
error = true;
}
if (m.binding == MemberBinding.INSTANCE) {
- Report.error (m.source_reference, "instance methods are not allowed outside of data types");
+ context.report.log_error (m.source_reference, "instance methods are not allowed outside of data types");
m.error = true;
error = true;
} else if (m.binding == MemberBinding.CLASS) {
- Report.error (m.source_reference, "class methods are not allowed outside of classes");
+ context.report.log_error (m.source_reference, "class methods are not allowed outside of classes");
m.error = true;
error = true;
}
if (type_reference == null) {
if (member_name == null) {
error = true;
- Report.error (source_reference, "Incomplete object creation expression");
+ context.report.log_error (source_reference, "Incomplete object creation expression");
return false;
}
var constructor = (Method) constructor_sym;
if (!(constructor_sym is CreationMethod)) {
error = true;
- Report.error (source_reference, "`%s' is not a creation method", constructor.get_full_name ());
+ context.report.log_error (source_reference, "`%s' is not a creation method", constructor.get_full_name ());
return false;
}
symbol_reference = type_sym;
} else {
error = true;
- Report.error (source_reference, "`%s' is not a class, struct, or error code", type_sym.get_full_name ());
+ context.report.log_error (source_reference, "`%s' is not a class, struct, or error code", type_sym.get_full_name ());
return false;
}
if (struct_creation) {
error = true;
- Report.error (source_reference, "syntax error, use `new' to create new objects");
+ context.report.log_error (source_reference, "syntax error, use `new' to create new objects");
return false;
}
if (cl.is_abstract) {
value_type = null;
error = true;
- Report.error (source_reference, "Can't create instance of abstract class `%s'", cl.get_full_name ());
+ context.report.log_error (source_reference, "Can't create instance of abstract class `%s'", cl.get_full_name ());
return false;
}
if (symbol_reference == null) {
error = true;
- Report.error (source_reference, "`%s' does not have a default constructor", cl.get_full_name ());
+ context.report.log_error (source_reference, "`%s' does not have a default constructor", cl.get_full_name ());
return false;
}
if (!in_target_type) {
error = true;
- Report.error (source_reference, "Access to non-public constructor `%s' denied", symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Access to non-public constructor `%s' denied", symbol_reference.get_full_name ());
return false;
}
}
if (context.profile == Profile.GOBJECT && st.is_simple_type () && symbol_reference == null && object_initializer.size == 0) {
error = true;
- Report.error (source_reference, "`%s' does not have a default constructor", st.get_full_name ());
+ context.report.log_error (source_reference, "`%s' does not have a default constructor", st.get_full_name ());
return false;
}
}
if (symbol_reference == null && argument_list.size != 0) {
value_type = null;
error = true;
- Report.error (source_reference, "No arguments allowed when constructing type `%s'", type.get_full_name ());
+ context.report.log_error (source_reference, "No arguments allowed when constructing type `%s'", type.get_full_name ());
return false;
}
if (is_yield_expression) {
if (!m.coroutine) {
error = true;
- Report.error (source_reference, "yield expression requires async method");
+ context.report.log_error (source_reference, "yield expression requires async method");
}
if (context.analyzer.current_method == null || !context.analyzer.current_method.coroutine) {
error = true;
- Report.error (source_reference, "yield expression not available outside async method");
+ context.report.log_error (source_reference, "yield expression not available outside async method");
}
} else if (m is CreationMethod) {
if (m.coroutine) {
error = true;
- Report.error (source_reference, "missing `yield' before async creation expression");
+ context.report.log_error (source_reference, "missing `yield' before async creation expression");
}
}
if (argument_list.size == 0) {
error = true;
- Report.error (source_reference, "Too few arguments, errors need at least 1 argument");
+ context.report.log_error (source_reference, "Too few arguments, errors need at least 1 argument");
} else {
Iterator<Expression> arg_it = argument_list.iterator ();
arg_it.next ();
var ex = arg_it.get ();
if (ex.value_type == null || !ex.value_type.compatible (context.analyzer.string_type)) {
error = true;
- Report.error (source_reference, "Invalid type for argument 1");
+ context.report.log_error (source_reference, "Invalid type for argument 1");
}
var format_literal = StringLiteral.get_format_literal (ex);
// simple statements, no side effects after method call
} else if (!(context.analyzer.current_symbol is Block)) {
// can't handle errors in field initializers
- Report.error (source_reference, "Field initializers must not throw errors");
+ context.report.log_error (source_reference, "Field initializers must not throw errors");
} else {
// store parent_node as we need to replace the expression in the old parent node later on
var old_parent_node = parent_node;
if (variable_type != null) {
if (variable_type is VoidType) {
error = true;
- Report.error (source_reference, "'void' not supported as parameter type");
+ context.report.log_error (source_reference, "'void' not supported as parameter type");
return false;
}
variable_type.check (context);
if (params_array) {
if (!(variable_type is ArrayType)) {
error = true;
- Report.error (source_reference, "parameter array expected");
+ context.report.log_error (source_reference, "parameter array expected");
return false;
} else if (((ArrayType) variable_type).rank != 1) {
error = true;
- Report.error (source_reference, "multi-dimensional parameter array not allowed");
+ context.report.log_error (source_reference, "multi-dimensional parameter array not allowed");
return false;
}
}
if (variable_array_type != null && variable_array_type.inline_allocated
&& !variable_array_type.fixed_length) {
error = true;
- Report.error (source_reference, "Inline allocated array as parameter requires to have fixed length");
+ context.report.log_error (source_reference, "Inline allocated array as parameter requires to have fixed length");
}
}
Report.warning (source_reference, "`null' incompatible with parameter type `%s'", variable_type.to_string ());
} else if (!(initializer is NullLiteral) && direction == ParameterDirection.OUT) {
error = true;
- Report.error (source_reference, "only `null' is allowed as default value for out parameters");
+ context.report.log_error (source_reference, "only `null' is allowed as default value for out parameters");
} else if (direction == ParameterDirection.IN && !initializer.value_type.compatible (variable_type)) {
error = true;
- Report.error (initializer.source_reference, "Cannot convert from `%s' to `%s'", initializer.value_type.to_string (), variable_type.to_string ());
+ context.report.log_error (initializer.source_reference, "Cannot convert from `%s' to `%s'", initializer.value_type.to_string (), variable_type.to_string ());
} else if (direction == ParameterDirection.REF) {
error = true;
- Report.error (source_reference, "default value not allowed for ref parameter");
+ context.report.log_error (source_reference, "default value not allowed for ref parameter");
} else if (!initializer.is_accessible (this)) {
error = true;
- Report.error (initializer.source_reference, "default value is less accessible than method `%s'", parent_symbol.get_full_name ());
+ context.report.log_error (initializer.source_reference, "default value is less accessible than method `%s'", parent_symbol.get_full_name ());
}
}
// check whether parameter type is at least as accessible as the method
if (!variable_type.is_accessible (this)) {
error = true;
- Report.error (source_reference, "parameter type `%s' is less accessible than method `%s'", variable_type.to_string (), parent_symbol.get_full_name ());
+ context.report.log_error (source_reference, "parameter type `%s' is less accessible than method `%s'", variable_type.to_string (), parent_symbol.get_full_name ());
}
}
}
if (inner.value_type == null) {
error = true;
- Report.error (source_reference, "internal error: unknown type of inner expression");
+ context.report.log_error (source_reference, "internal error: unknown type of inner expression");
return false;
}
if (inner.value_type is PointerType) {
var pointer_type = (PointerType) inner.value_type;
if (pointer_type.base_type is ReferenceType || pointer_type.base_type is VoidType) {
error = true;
- Report.error (source_reference, "Pointer indirection not supported for this expression");
+ context.report.log_error (source_reference, "Pointer indirection not supported for this expression");
return false;
}
value_type = pointer_type.base_type;
value_type.value_owned = false;
} else {
error = true;
- Report.error (source_reference, "Pointer indirection not supported for this expression");
+ context.report.log_error (source_reference, "Pointer indirection not supported for this expression");
return false;
}
if (!(inner.value_type is IntegerType) && !(inner.value_type is FloatingType) && !(inner.value_type is PointerType)) {
error = true;
- Report.error (source_reference, "unsupported lvalue in postfix expression");
+ context.report.log_error (source_reference, "unsupported lvalue in postfix expression");
return false;
}
if (ma.prototype_access) {
error = true;
- Report.error (source_reference, "Access to instance member `%s' denied", ma.symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Access to instance member `%s' denied", ma.symbol_reference.get_full_name ());
return false;
}
unowned ElementAccess ea = (ElementAccess) inner;
if (!(ea.container.value_type is ArrayType)) {
error = true;
- Report.error (source_reference, "unsupported lvalue in postfix expression");
+ context.report.log_error (source_reference, "unsupported lvalue in postfix expression");
return false;
}
} else {
error = true;
- Report.error (source_reference, "unsupported lvalue in postfix expression");
+ context.report.log_error (source_reference, "unsupported lvalue in postfix expression");
return false;
}
if (prop.set_accessor == null || !prop.set_accessor.writable) {
ma.error = true;
- Report.error (ma.source_reference, "Property `%s' is read-only", prop.get_full_name ());
+ context.report.log_error (ma.source_reference, "Property `%s' is read-only", prop.get_full_name ());
return false;
}
}
&& ((ObjectTypeSymbol) parent_symbol).is_subtype_of (context.analyzer.object_type)) {
if (!is_valid_name (name)) {
error = true;
- Report.error (source_reference, "Name `%s' is not valid for a GLib.Object property", name);
+ context.report.log_error (source_reference, "Name `%s' is not valid for a GLib.Object property", name);
}
}
var cl = (Class) parent_symbol;
if (cl.is_compact && cl.base_class != null) {
error = true;
- Report.error (source_reference, "Abstract and virtual properties may not be declared in derived compact classes");
+ context.report.log_error (source_reference, "Abstract and virtual properties may not be declared in derived compact classes");
return false;
}
if (cl.is_opaque) {
error = true;
- Report.error (source_reference, "Abstract and virtual properties may not be declared in opaque compact classes");
+ context.report.log_error (source_reference, "Abstract and virtual properties may not be declared in opaque compact classes");
return false;
}
}
var cl = (Class) parent_symbol;
if (!cl.is_abstract) {
error = true;
- Report.error (source_reference, "Abstract properties may not be declared in non-abstract classes");
+ context.report.log_error (source_reference, "Abstract properties may not be declared in non-abstract classes");
return false;
}
} else if (!(parent_symbol is Interface)) {
error = true;
- Report.error (source_reference, "Abstract properties may not be declared outside of classes and interfaces");
+ context.report.log_error (source_reference, "Abstract properties may not be declared outside of classes and interfaces");
return false;
}
} else if (is_virtual) {
if (!(parent_symbol is Class) && !(parent_symbol is Interface)) {
error = true;
- Report.error (source_reference, "Virtual properties may not be declared outside of classes and interfaces");
+ context.report.log_error (source_reference, "Virtual properties may not be declared outside of classes and interfaces");
return false;
}
} else if (overrides) {
if (!(parent_symbol is Class)) {
error = true;
- Report.error (source_reference, "Properties may not be overridden outside of classes");
+ context.report.log_error (source_reference, "Properties may not be overridden outside of classes");
return false;
}
} else if (access == SymbolAccessibility.PROTECTED) {
if (!(parent_symbol is Class) && !(parent_symbol is Interface)) {
error = true;
- Report.error (source_reference, "Protected properties may not be declared outside of classes and interfaces");
+ context.report.log_error (source_reference, "Protected properties may not be declared outside of classes and interfaces");
return false;
}
}
if (property_type is VoidType) {
error = true;
- Report.error (source_reference, "'void' not supported as property type");
+ context.report.log_error (source_reference, "'void' not supported as property type");
return false;
}
if (get_accessor == null && set_accessor == null) {
error = true;
- Report.error (source_reference, "Property `%s' must have a `get' accessor and/or a `set' mutator", get_full_name ());
+ context.report.log_error (source_reference, "Property `%s' must have a `get' accessor and/or a `set' mutator", get_full_name ());
return false;
}
}
if (initializer != null && field == null && !is_abstract) {
- Report.error (source_reference, "Property `%s' with custom `get' accessor and/or `set' mutator cannot have `default' value", get_full_name ());
+ context.report.log_error (source_reference, "Property `%s' with custom `get' accessor and/or `set' mutator cannot have `default' value", get_full_name ());
}
if (initializer != null) {
// check whether property type is at least as accessible as the property
if (!property_type.is_accessible (this)) {
error = true;
- Report.error (source_reference, "property type `%s' is less accessible than property `%s'", property_type.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "property type `%s' is less accessible than property `%s'", property_type.to_string (), get_full_name ());
}
if (overrides && base_property == null && base_interface_property == null) {
- Report.error (source_reference, "%s: no suitable property found to override", get_full_name ());
+ context.report.log_error (source_reference, "%s: no suitable property found to override", get_full_name ());
}
if (!external_package && !overrides && !hides && get_hidden_member () != null) {
if (set_accessor != null && set_accessor.construction) {
if (access != SymbolAccessibility.PUBLIC) {
error = true;
- Report.error (source_reference, "%s: construct properties must be public", get_full_name ());
+ context.report.log_error (source_reference, "%s: construct properties must be public", get_full_name ());
}
}
if (initializer != null && !initializer.error && initializer.value_type != null && !(initializer.value_type.compatible (property_type))) {
error = true;
- Report.error (initializer.source_reference, "Expected initializer of type `%s' but got `%s'", property_type.to_string (), initializer.value_type.to_string ());
+ context.report.log_error (initializer.source_reference, "Expected initializer of type `%s' but got `%s'", property_type.to_string (), initializer.value_type.to_string ());
}
context.analyzer.current_source_file = old_source_file;
// Hopefully good as is
} else if (!value_type.value_owned && source_reference.file.file_type == SourceFileType.SOURCE) {
error = true;
- Report.error (source_reference, "unowned return value for getter of property `%s' not supported without accessor", prop.get_full_name ());
+ context.report.log_error (source_reference, "unowned return value for getter of property `%s' not supported without accessor", prop.get_full_name ());
}
} else if (value_type.value_owned && (source_reference == null || source_reference.file == null)) {
if (value_type is DelegateType || value_type is PointerType || (value_type is ValueType && !value_type.nullable)) {
if ((prop.is_abstract || prop.is_virtual || prop.overrides) && access == SymbolAccessibility.PRIVATE) {
error = true;
- Report.error (source_reference, "Property `%s' with private accessor cannot be marked as abstract, virtual or override", prop.get_full_name ());
+ context.report.log_error (source_reference, "Property `%s' with private accessor cannot be marked as abstract, virtual or override", prop.get_full_name ());
return false;
}
if (context.profile == Profile.POSIX && construction) {
error = true;
- Report.error (source_reference, "`construct' is not supported in POSIX profile");
+ context.report.log_error (source_reference, "`construct' is not supported in POSIX profile");
return false;
} else if (construction && !((TypeSymbol) prop.parent_symbol).is_subtype_of (context.analyzer.object_type)) {
error = true;
- Report.error (source_reference, "construct properties require `GLib.Object'");
+ context.report.log_error (source_reference, "construct properties require `GLib.Object'");
return false;
} else if (construction && !context.analyzer.is_gobject_property (prop)) {
//TODO Report an error for external property too
Report.warning (source_reference, "construct properties not supported for specified property type");
} else {
error = true;
- Report.error (source_reference, "construct properties not supported for specified property type");
+ context.report.log_error (source_reference, "construct properties not supported for specified property type");
return false;
}
}
if (body != null && prop.is_abstract) {
error = true;
- Report.error (source_reference, "Accessor of abstract property `%s' cannot have body", prop.get_full_name ());
+ context.report.log_error (source_reference, "Accessor of abstract property `%s' cannot have body", prop.get_full_name ());
return false;
}
if (!(inner is MemberAccess || inner is ElementAccess)) {
error = true;
- Report.error (source_reference, "Reference transfer not supported for this expression");
+ context.report.log_error (source_reference, "Reference transfer not supported for this expression");
return false;
}
if (inner.value_type is ArrayType && ((ArrayType) inner.value_type).inline_allocated) {
error = true;
- Report.error (source_reference, "Ownership of inline-allocated array cannot be transferred");
+ context.report.log_error (source_reference, "Ownership of inline-allocated array cannot be transferred");
return false;
}
&& !(inner.value_type is PointerType)
&& !is_owned_delegate) {
error = true;
- Report.error (source_reference, "No reference to be transferred");
+ context.report.log_error (source_reference, "No reference to be transferred");
return false;
}
if (regex != null) { /* Regex is valid. */ }
} catch (RegexError err) {
error = true;
- Report.error (source_reference, "Invalid regular expression `%s'.", value);
+ context.report.log_error (source_reference, "Invalid regular expression `%s'.", value);
return false;
}
if (context.analyzer.current_return_type == null) {
error = true;
- Report.error (source_reference, "Return not allowed in this context");
+ context.report.log_error (source_reference, "Return not allowed in this context");
return false;
}
if (return_expression == null) {
if (!(context.analyzer.current_return_type is VoidType)) {
error = true;
- Report.error (source_reference, "Return without value in non-void function");
+ context.report.log_error (source_reference, "Return without value in non-void function");
}
return !error;
}
if (context.analyzer.current_return_type is VoidType) {
error = true;
- Report.error (source_reference, "Return with value in void function");
+ context.report.log_error (source_reference, "Return with value in void function");
return false;
}
if (return_expression.value_type == null) {
error = true;
- Report.error (source_reference, "Invalid expression in return value");
+ context.report.log_error (source_reference, "Invalid expression in return value");
return false;
}
if (!return_expression.value_type.compatible (context.analyzer.current_return_type)) {
error = true;
- Report.error (source_reference, "Return: Cannot convert from `%s' to `%s'", return_expression.value_type.to_string (), context.analyzer.current_return_type.to_string ());
+ context.report.log_error (source_reference, "Return: Cannot convert from `%s' to `%s'", return_expression.value_type.to_string (), context.analyzer.current_return_type.to_string ());
return false;
}
if (return_expression.value_type.is_disposable () &&
!context.analyzer.current_return_type.value_owned) {
error = true;
- Report.error (source_reference, "Return value transfers ownership but method return type hasn't been declared to transfer ownership");
+ context.report.log_error (source_reference, "Return value transfers ownership but method return type hasn't been declared to transfer ownership");
return false;
}
if (local != null && local.variable_type.is_disposable () &&
!context.analyzer.current_return_type.value_owned) {
error = true;
- Report.error (source_reference, "Local variable with strong reference used as return value and method return type has not been declared to transfer ownership");
+ context.report.log_error (source_reference, "Local variable with strong reference used as return value and method return type has not been declared to transfer ownership");
return false;
}
unowned Class? parent_cl = parent_symbol as Class;
if (parent_cl != null && parent_cl.is_compact) {
error = true;
- Report.error (source_reference, "Signals are not supported in compact classes");
+ context.report.log_error (source_reference, "Signals are not supported in compact classes");
return false;
}
foreach (DataType base_type in parent_cl.get_base_types ()) {
if (SemanticAnalyzer.symbol_lookup_inherited (base_type.type_symbol, name) is Signal) {
error = true;
- Report.error (source_reference, "Signals with the same name as a signal in a base type are not supported");
+ context.report.log_error (source_reference, "Signals with the same name as a signal in a base type are not supported");
return false;
}
}
if (return_type.type_symbol == context.analyzer.va_list_type.type_symbol) {
error = true;
- Report.error (source_reference, "`%s' not supported as return type", return_type.type_symbol.get_full_name ());
+ context.report.log_error (source_reference, "`%s' not supported as return type", return_type.type_symbol.get_full_name ());
return false;
}
foreach (Parameter param in parameters) {
if (param.ellipsis) {
- Report.error (param.source_reference, "Signals with variable argument lists are not supported");
+ context.report.log_error (param.source_reference, "Signals with variable argument lists are not supported");
return false;
}
if (!external_package && !hides && get_hidden_member () != null) {
- Report.warning (source_reference, "%s hides inherited signal `%s'. Use the `new' keyword if hiding was intentional", get_full_name (), get_hidden_member ().get_full_name ());
+ context.report.log_warning (source_reference, "%s hides inherited signal `%s'. Use the `new' keyword if hiding was intentional", get_full_name (), get_hidden_member ().get_full_name ());
}
return !error;
if (container.value_type == null) {
error = true;
- Report.error (container.source_reference, "Invalid container expression");
+ context.report.log_error (container.source_reference, "Invalid container expression");
return false;
}
if (lvalue) {
error = true;
- Report.error (container.source_reference, "Slice expressions cannot be used as lvalue");
+ context.report.log_error (container.source_reference, "Slice expressions cannot be used as lvalue");
return false;
}
/* check if the index is of type integer */
if (!(start.value_type is IntegerType || start.value_type is EnumValueType)) {
error = true;
- Report.error (start.source_reference, "Expression of integer type expected");
+ context.report.log_error (start.source_reference, "Expression of integer type expected");
}
if (!(stop.value_type is IntegerType || stop.value_type is EnumValueType)) {
error = true;
- Report.error (stop.source_reference, "Expression of integer type expected");
+ context.report.log_error (stop.source_reference, "Expression of integer type expected");
}
} else {
var slice_method = container.value_type.get_member ("slice") as Method;
}
error = true;
- Report.error (source_reference, "The expression `%s' does not denote an array", container.value_type.to_string ());
+ context.report.log_error (source_reference, "The expression `%s' does not denote an array", container.value_type.to_string ());
}
return !error;
if (!(base_type is ValueType)) {
error = true;
- Report.error (source_reference, "The base type `%s' of struct `%s' is not a struct", base_type.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "The base type `%s' of struct `%s' is not a struct", base_type.to_string (), get_full_name ());
return false;
}
// check whether base type is at least as accessible as the struct
if (!base_type.is_accessible (this)) {
error = true;
- Report.error (source_reference, "base type `%s' is less accessible than struct `%s'", base_type.to_string (), get_full_name ());
+ context.report.log_error (source_reference, "base type `%s' is less accessible than struct `%s'", base_type.to_string (), get_full_name ());
}
}
if (f.binding == MemberBinding.INSTANCE && is_recursive_value_type (context, f.variable_type)) {
error = true;
- Report.error (f.source_reference, "Recursive value types are not allowed");
+ context.report.log_error (f.source_reference, "Recursive value types are not allowed");
return false;
}
if (f.binding == MemberBinding.INSTANCE && f.initializer != null) {
error = true;
- Report.error (f.source_reference, "Instance field initializers not supported");
+ context.report.log_error (f.source_reference, "Instance field initializers not supported");
return false;
}
// for backing property fields a dedicated error will be reported later
if (!(f in property_fields) && !(f.initializer.value_type is NullType) && f.variable_type.is_disposable () && f.variable_type.value_owned) {
error = true;
- Report.error (f.initializer.source_reference, "Owned static struct fields can only be initialized in a function or method");
+ context.report.log_error (f.initializer.source_reference, "Owned static struct fields can only be initialized in a function or method");
}
}
}
unowned Field? field = prop.field;
if (field != null && field.initializer != null && !(field.initializer.value_type is NullType) && field.variable_type.is_disposable () && field.variable_type.value_owned) {
error = true;
- Report.error (field.initializer.source_reference, "Owned static struct properties can only be initialized in a function or method");
+ context.report.log_error (field.initializer.source_reference, "Owned static struct properties can only be initialized in a function or method");
}
}
}
}
if (base_type == null && !has_instance_field && !is_boolean_type () && !is_integer_type () && !is_floating_type ()) {
error = true;
- Report.error (source_reference, "struct `%s' cannot be empty", get_full_name ());
+ context.report.log_error (source_reference, "struct `%s' cannot be empty", get_full_name ());
} else if (base_type != null && has_instance_field) {
error = true;
- Report.error (source_reference, "derived struct `%s' may not have instance fields", get_full_name ());
+ context.report.log_error (source_reference, "derived struct `%s' may not have instance fields", get_full_name ());
}
}
(!(expression.value_type is IntegerType) &&
!(expression.value_type is EnumValueType) &&
!expression.value_type.compatible (context.analyzer.string_type))) {
- Report.error (expression.source_reference, "Integer or string expression expected");
+ context.report.log_error (expression.source_reference, "Integer or string expression expected");
error = true;
return false;
}
if (value != null && !labelset.add (value)) {
error = true;
- Report.error (label.expression.source_reference, "Switch statement already contains this label");
+ context.report.log_error (label.expression.source_reference, "Switch statement already contains this label");
}
}
}
checked = true;
if (context.profile == Profile.POSIX) {
- Report.error (source_reference, "`throws' is not supported in POSIX profile");
+ context.report.log_error (source_reference, "`throws' is not supported in POSIX profile");
error = true;
return false;
}
}
if (error_expression.value_type == null) {
- Report.error (error_expression.source_reference, "invalid error expression");
+ context.report.log_error (error_expression.source_reference, "invalid error expression");
error = true;
return false;
}
if (context.profile == Profile.GOBJECT && !(error_expression.value_type is ErrorType)) {
- Report.error (error_expression.source_reference, "`%s' is not an error type", error_expression.value_type.to_string ());
+ context.report.log_error (error_expression.source_reference, "`%s' is not an error type", error_expression.value_type.to_string ());
error = true;
return false;
}
checked = true;
if (context.profile == Profile.POSIX) {
- Report.error (source_reference, "`try' is not supported in POSIX profile");
+ context.report.log_error (source_reference, "`try' is not supported in POSIX profile");
error = true;
return false;
}
checked = true;
- Report.error (source_reference, "tuples are not supported");
+ context.report.log_error (source_reference, "tuples are not supported");
error = true;
return false;
}
type_reference.check (context);
if (expression.value_type == null) {
- Report.error (expression.source_reference, "invalid left operand");
+ context.report.log_error (expression.source_reference, "invalid left operand");
error = true;
return false;
}
}
if (type_reference is ErrorType && !(expression.value_type is ErrorType)) {
- Report.error (expression.source_reference, "`%s' must be an error", expression.to_string ());
+ context.report.log_error (expression.source_reference, "`%s' must be an error", expression.to_string ());
error = true;
return false;
}
if (context.profile == Profile.GOBJECT && type_reference.has_type_arguments ()) {
- Report.warning (_data_type.source_reference, "Type argument list has no effect");
+ context.report.log_warning (_data_type.source_reference, "Type argument list has no effect");
}
value_type = context.analyzer.bool_type;
value_type = context.analyzer.type_type;
if (context.profile == Profile.GOBJECT && type_reference.has_type_arguments ()) {
- Report.warning (_data_type.source_reference, "Type argument list without effect");
+ context.report.log_warning (_data_type.source_reference, "Type argument list without effect");
}
if (_data_type is ArrayType && ((ArrayType) _data_type).element_type.type_symbol != context.analyzer.string_type.type_symbol) {
- Report.warning (_data_type.source_reference, "Arrays do not have a `GLib.Type', with the exception of `string[]'");
+ context.report.log_warning (_data_type.source_reference, "Arrays do not have a `GLib.Type', with the exception of `string[]'");
}
return !error;
return false;
} else if (inner.value_type == null) {
error = true;
- Report.error (inner.source_reference, "Invalid inner operand");
+ context.report.log_error (inner.source_reference, "Invalid inner operand");
return false;
}
if (inner.value_type is FieldPrototype || inner.value_type is PropertyPrototype) {
error = true;
- Report.error (inner.source_reference, "Access to instance member `%s' denied", inner.symbol_reference.get_full_name ());
+ context.report.log_error (inner.source_reference, "Access to instance member `%s' denied", inner.symbol_reference.get_full_name ());
return false;
}
// integer or floating point type
if (!is_numeric_type (inner.value_type)) {
error = true;
- Report.error (source_reference, "Operator not supported for `%s'", inner.value_type.to_string ());
+ context.report.log_error (source_reference, "Operator not supported for `%s'", inner.value_type.to_string ());
return false;
}
// boolean type
if (inner.value_type.nullable || !inner.value_type.compatible (context.analyzer.bool_type)) {
error = true;
- Report.error (source_reference, "Operator not supported for `%s'", inner.value_type.to_string ());
+ context.report.log_error (source_reference, "Operator not supported for `%s'", inner.value_type.to_string ());
return false;
}
// integer type
if (!is_integer_type (inner.value_type) && !(inner.value_type is EnumValueType)) {
error = true;
- Report.error (source_reference, "Operator not supported for `%s'", inner.value_type.to_string ());
+ context.report.log_error (source_reference, "Operator not supported for `%s'", inner.value_type.to_string ());
return false;
}
// integer type
if (!is_integer_type (inner.value_type)) {
error = true;
- Report.error (source_reference, "Operator not supported for `%s'", inner.value_type.to_string ());
+ context.report.log_error (source_reference, "Operator not supported for `%s'", inner.value_type.to_string ());
return false;
}
if (!(inner is MemberAccess)) {
error = true;
- Report.error (source_reference, "Prefix operators not supported for this expression");
+ context.report.log_error (source_reference, "Prefix operators not supported for this expression");
return false;
}
value_type = inner.value_type;
} else {
error = true;
- Report.error (source_reference, "ref and out method arguments can only be used with fields, parameters, local variables, and array element access");
+ context.report.log_error (source_reference, "ref and out method arguments can only be used with fields, parameters, local variables, and array element access");
return false;
}
if (inner.symbol_reference != null && inner.symbol_reference.get_attribute ("GtkChild") != null) {
error = true;
- Report.error (source_reference, "Assignment of [GtkChild] `%s' is not allowed", inner.symbol_reference.get_full_name ());
+ context.report.log_error (source_reference, "Assignment of [GtkChild] `%s' is not allowed", inner.symbol_reference.get_full_name ());
return false;
}
break;
default:
error = true;
- Report.error (source_reference, "internal error: unsupported unary operator");
+ context.report.log_error (source_reference, "internal error: unsupported unary operator");
return false;
}
if (!(resource is MemberAccess && resource.symbol_reference is Lockable)) {
error = true;
resource.error = true;
- Report.error (resource.source_reference, "Expression is either not a member access or does not denote a lockable member");
+ context.report.log_error (resource.source_reference, "Expression is either not a member access or does not denote a lockable member");
return false;
}
if (resource.symbol_reference.parent_symbol != context.analyzer.current_class) {
error = true;
resource.error = true;
- Report.error (resource.source_reference, "Only members of the current class are lockable");
+ context.report.log_error (resource.source_reference, "Only members of the current class are lockable");
return false;
}
if (context.analyzer.current_class.is_compact) {
error = true;
resource.error = true;
- Report.error (resource.source_reference, "Only members of the non-compact classes are lockable");
+ context.report.log_error (resource.source_reference, "Only members of the non-compact classes are lockable");
return false;
}
if (!is_object_or_value_type (expression.value_type)) {
error = true;
- Report.error (expression.source_reference, "with statement expects an object or basic type");
+ context.report.log_error (expression.source_reference, "with statement expects an object or basic type");
return false;
}
if (context.analyzer.current_method == null || !context.analyzer.current_method.coroutine) {
error = true;
- Report.error (source_reference, "yield statement not available outside async method");
+ context.report.log_error (source_reference, "yield statement not available outside async method");
}
return !error;