From: Jean Privat Date: Wed, 15 Apr 2015 01:14:56 +0000 (+0700) Subject: src: improve messages (and sometime location) of errors and warnings X-Git-Tag: v0.7.4~23^2~1 X-Git-Url: http://nitlanguage.org src: improve messages (and sometime location) of errors and warnings Signed-off-by: Jean Privat --- diff --git a/src/annotation.nit b/src/annotation.nit index 882b645..73c9985 100644 --- a/src/annotation.nit +++ b/src/annotation.nit @@ -30,7 +30,7 @@ redef class Prod var res = get_annotations(name) if res.is_empty then return null if res.length > 1 then - modelbuilder.error(res[1], "Error: multiple annotation `{name}`. A previous one is defined line {res[0].location.line_start}") + modelbuilder.error(res[1], "Syntax Error: multiple `{name}`. A previous one is defined line {res[0].location.line_start}.") end return res.first end @@ -47,7 +47,7 @@ redef class AAnnotation if arg != null then return arg end - modelbuilder.error(self, "Annotation error: \"{name}\" expects a single String as argument.") + modelbuilder.error(self, "Syntax Error: `{name}` expects a single String as argument.") return null end @@ -61,7 +61,7 @@ redef class AAnnotation if arg != null then return arg end - modelbuilder.error(self, "Annotation error: \"{name}\" expects a single Int as argument.") + modelbuilder.error(self, "Syntax Error: `{name}` expects a single Int as argument.") return null end @@ -75,7 +75,7 @@ redef class AAnnotation if arg != null then return arg end - modelbuilder.error(self, "Annotation error: \"{name}\" expects a single identifier as argument.") + modelbuilder.error(self, "Syntax Error: `{name}` expects a single identifier as argument.") return null end end @@ -142,7 +142,7 @@ redef class ModelBuilder for annot in annotations do locs.add(annot.location) toolcontext.error(mmodule.location, - "Priority conflict on annotation {name}, it has been defined in: {locs.join(", ")}") + "Error: priority conflict on annotation `{name}`, it has been defined in: {locs.join(", ")}.") end return annotations.first end diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 8c9e4b7..90cb6a7 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -95,12 +95,12 @@ redef class ToolContext # Default is nitstack opt_stacktrace.value = "nitstack" else - print "Error: unknown value `{st}` for --stacktrace. Use `none`, `libunwind`, `nitstack` or `auto`." + print "Option Error: unknown value `{st}` for --stacktrace. Use `none`, `libunwind`, `nitstack` or `auto`." exit(1) end if opt_output.value != null and opt_dir.value != null then - print "Error: cannot use both --dir and --output" + print "Option Error: cannot use both --dir and --output" exit(1) end @@ -463,16 +463,18 @@ endif var makeflags = self.toolcontext.opt_make_flags.value if makeflags == null then makeflags = "" - self.toolcontext.info("make -B -C {compile_dir} -f {makename} -j 4 {makeflags}", 2) + + var command = "make -B -C {compile_dir} -f {makename} -j 4 {makeflags}" + self.toolcontext.info(command, 2) var res if self.toolcontext.verbose_level >= 3 then - res = sys.system("make -B -C {compile_dir} -f {makename} -j 4 {makeflags} 2>&1") + res = sys.system("{command} 2>&1") else - res = sys.system("make -B -C {compile_dir} -f {makename} -j 4 {makeflags} 2>&1 >/dev/null") + res = sys.system("{command} 2>&1 >/dev/null") end if res != 0 then - toolcontext.error(null, "make failed! Error code: {res}.") + toolcontext.error(null, "Compilation Error: `make` failed with error code: {res}. The command was `{command}`.") end end end @@ -689,7 +691,7 @@ extern void nitni_global_ref_decr( struct nitni_ref *ref ); var finalize_meth = mainmodule.try_get_primitive_method("finalize", finalizable_type.mclass) if finalize_meth == null then - modelbuilder.toolcontext.error(null, "The `Finalizable` class doesn't declare the `finalize` method.") + modelbuilder.toolcontext.error(null, "Error: the `Finalizable` class does not declare the `finalize` method.") return end @@ -3159,7 +3161,7 @@ var modelbuilder = new ModelBuilder(model, toolcontext) var arguments = toolcontext.option_context.rest if arguments.length > 1 and toolcontext.opt_output.value != null then - print "Error: --output needs a single source file. Do you prefer --dir?" + print "Option Error: --output needs a single source file. Do you prefer --dir?" exit 1 end diff --git a/src/doc/doc_phases/doc_html.nit b/src/doc/doc_phases/doc_html.nit index 7d38bc0..83b02f9 100644 --- a/src/doc/doc_phases/doc_html.nit +++ b/src/doc/doc_phases/doc_html.nit @@ -87,7 +87,7 @@ redef class ToolContext var git_dir = opt_github_gitdir var opts = [upstream.value, base_sha.value, git_dir.value] if not opts.has_only(null) and opts.has(null) then - print "Error: Options {upstream.names.first}, " + + print "Option Error: options {upstream.names.first}, " + "{base_sha.names.first} and {git_dir.names.first} " + "are required to enable the GitHub plugin" exit 1 @@ -120,7 +120,7 @@ class RenderHTMLPhase var dir = ctx.nit_dir sharedir = dir/"share/nitdoc" if not sharedir.file_exists then - print "Error: Cannot locate nitdoc share files. Uses --sharedir or envvar NIT_DIR" + print "Error: cannot locate nitdoc share files. Uses --sharedir or envvar NIT_DIR" abort end end diff --git a/src/doc/vim_autocomplete.nit b/src/doc/vim_autocomplete.nit index edbc126..7781fe8 100644 --- a/src/doc/vim_autocomplete.nit +++ b/src/doc/vim_autocomplete.nit @@ -302,7 +302,7 @@ private class AutocompletePhase stream.close var error = stream.last_error if error != null then - toolcontext.error(null, "Failed to write Vim autocomplete file: {error}") + toolcontext.error(null, "Error: failed to write Vim autocomplete file: {error}.") end end end diff --git a/src/ffi/c_compiler_options.nit b/src/ffi/c_compiler_options.nit index 878785c..1618f9e 100644 --- a/src/ffi/c_compiler_options.nit +++ b/src/ffi/c_compiler_options.nit @@ -48,13 +48,13 @@ private class CCompilerOptionsPhase var modelbuilder = toolcontext.modelbuilder if not nmoduledecl isa AModuledecl then - modelbuilder.error(nat, "Syntax error: only the declaration of modules may use \"{annotation_name}\".") + modelbuilder.error(nat, "Syntax Error: only the declaration of modules may use `{annotation_name}`.") return end var args = nat.n_args if args.is_empty then - modelbuilder.error(nat, "Syntax error: \"{annotation_name}\" expects at least one argument.") + modelbuilder.error(nat, "Syntax Error: `{annotation_name}` expects at least one argument.") return end @@ -69,14 +69,14 @@ private class CCompilerOptionsPhase # We support calls to "exec" only var exec_args = expr.n_args.to_a if expr.n_id.text != "exec" or exec_args.is_empty then - modelbuilder.error(nat, "Syntax error: \"{annotation_name}\" accepts only calls to `exec` with the command as arguments.") + modelbuilder.error(nat, "Syntax Error: `{annotation_name}` accepts only calls to `exec` with the command as arguments.") return end var exec_args_as_strings = new Array[String] for exec_arg in exec_args do if not exec_arg isa AStringFormExpr then - modelbuilder.error(nat, "Syntax error: calls to `exec` expects the arguments to be String literals.") + modelbuilder.error(nat, "Syntax Error: calls to `exec` expects the arguments to be String literals.") return else var arg_string = exec_arg.collect_text @@ -88,7 +88,7 @@ private class CCompilerOptionsPhase var opt = new ExecCCompilerOption(exec_args_as_strings, expr) options.add(opt) else - modelbuilder.error(nat, "Syntax error: \"{annotation_name}\" expects its arguments to be the name of the package as String literals.") + modelbuilder.error(nat, "Syntax Error: `{annotation_name}` expects its arguments to be the name of the package as String literals.") return end end @@ -113,14 +113,14 @@ private class CCompilerOptionsPhase # check result var status = proc.status if status != 0 then - modelbuilder.error(opt.exec_node, "Annotation error: Something went wrong executing the argument of annotation \"{annotation_name}\", make sure the command is valid.") + modelbuilder.error(opt.exec_node, "Error: something went wrong when executing the argument of `{annotation_name}`, make sure the command is valid.") return end # process result var result = proc.read_all.replace("\n", " ") if result.is_empty then - modelbuilder.error(opt.exec_node, "Annotation error: Got no result from the command, make sure it is valid.") + modelbuilder.error(opt.exec_node, "Error: got no result from the command, make sure it is valid.") return end simplified_options.add(new DirectCCompilerOption(result)) @@ -147,7 +147,7 @@ private class CCompilerOptionsPhase if annots != null then var items = annots.n_items if items.length > 1 then - modelbuilder.error(annots, "Annotation error: `annotation_name` accepts only a single annotation, the platform name") + modelbuilder.error(annots, "Syntax Error: `{annotation_name}` accepts only a single annotation, the platform name.") return end assert items.length == 1 diff --git a/src/ffi/extern_classes.nit b/src/ffi/extern_classes.nit index 4e8f45d..6b53008 100644 --- a/src/ffi/extern_classes.nit +++ b/src/ffi/extern_classes.nit @@ -38,8 +38,8 @@ private class ExternClassesTypingPhaseAst if code_block == null then return if nclassdef.n_kwredef != null then - # A redef cannot specifiy a different extern type - toolcontext.error(nclassdef.location, "Only the introduction of a class can specify an extern type.") + # A redef cannot specify a different extern type + toolcontext.error(nclassdef.location, "FFI Error: only the introduction of a class can declare an extern type.") return end @@ -118,7 +118,7 @@ redef class MClass else # detect conflict if super_ftype != ftype_b then - v.toolcontext.error(null, "Extern type conflict in {self}") + v.toolcontext.error(null, "FFI Error: extern type conflict in `{self}`.") return null end end diff --git a/src/ffi/extra_java_files.nit b/src/ffi/extra_java_files.nit index 67a5f9d..71485cc 100644 --- a/src/ffi/extra_java_files.nit +++ b/src/ffi/extra_java_files.nit @@ -45,13 +45,13 @@ private class JavaExtraFilesPhase var modelbuilder = toolcontext.modelbuilder if not nmoduledecl isa AModuledecl then - modelbuilder.error(nat, "Syntax error: only the declaration of modules may use \"{annot_name}\".") + modelbuilder.error(nat, "Syntax Error: only the declaration of modules may use `{annot_name}`.") return end var args = nat.n_args if args.is_empty then - modelbuilder.error(nat, "Syntax error: \"{annot_name}\" expects at least one argument.") + modelbuilder.error(nat, "Syntax Error: `{annot_name}` expects at least one argument.") return end @@ -64,7 +64,7 @@ private class JavaExtraFilesPhase mmodule.extra_java_files = java_files end - var format_error = "Syntax error: \"{annot_name}\" expects its arguments to be paths to java files." + var format_error = "Syntax Error: `{annot_name}` expects its arguments to be paths to java files." for arg in args do var path = arg.as_string if path == null then @@ -77,7 +77,7 @@ private class JavaExtraFilesPhase if source_file != null then path = "{source_file.filename.dirname}/{path}" if not path.file_exists then - modelbuilder.error(nat, "FFI with Java error: file \"{path}\" not found.") + modelbuilder.error(nat, "FFI with Java Error: file `{path}` not found.") continue end diff --git a/src/ffi/ffi_base.nit b/src/ffi/ffi_base.nit index 59f46b3..b8a8103 100644 --- a/src/ffi/ffi_base.nit +++ b/src/ffi/ffi_base.nit @@ -63,14 +63,14 @@ class FFILanguageAssignationPhase var identified = v.identify_language(n) if identified then if found and identified then - toolcontext.error(n.location, "Two languages identified as possible handlers.") + toolcontext.error(n.location, "FFI Error: two languages identified as possible handlers.") end n.language = v found = true end end - if not found then toolcontext.error(n.location, "Unsupported language.") + if not found then toolcontext.error(n.location, "FFI Error: unsupported language.") end end diff --git a/src/ffi/java.nit b/src/ffi/java.nit index 7827dac..830e68c 100644 --- a/src/ffi/java.nit +++ b/src/ffi/java.nit @@ -296,7 +296,7 @@ redef class AMethPropdef assert sys_class != null var sys_jni_env_meth = modelbuilder.try_get_mproperty_by_name2(self, mmodule, sys_class.mclass_type, "jni_env") if sys_jni_env_meth == null or not sys_jni_env_meth isa MMethod then - toolcontext.error(self.location, "Java FFI error: you must import the `java` module when using the FFI with Java") + toolcontext.error(self.location, "Java FFI Error: you must import the `java` module when using the FFI with Java") return end diff --git a/src/ffi/pkgconfig.nit b/src/ffi/pkgconfig.nit index bd62de3..7665b7a 100644 --- a/src/ffi/pkgconfig.nit +++ b/src/ffi/pkgconfig.nit @@ -39,7 +39,7 @@ class PkgconfigPhase var modelbuilder = toolcontext.modelbuilder if not nmoduledecl isa AModuledecl then - modelbuilder.error(nat, "Syntax error: only the declaration of modules may use \"pkgconfig\".") + modelbuilder.error(nat, "Syntax Error: only the declaration of modules may use `pkgconfig`.") return end @@ -58,7 +58,7 @@ class PkgconfigPhase for arg in args do var pkg = arg.as_string if pkg == null then - modelbuilder.error(nat, "Syntax error: \"pkgconfig\" expects its arguments to be the name of the package as String literals.") + modelbuilder.error(nat, "Syntax Error: `pkgconfig` expects its arguments to be the name of the package as String literals.") return end @@ -71,7 +71,7 @@ class PkgconfigPhase proc_which.wait var status = proc_which.status if status != 0 then - modelbuilder.error(nat, "Error: program pkg-config not found, make sure it is installed.") + modelbuilder.error(nat, "Error: program `pkg-config` not found, make sure it is installed.") return end @@ -80,10 +80,10 @@ class PkgconfigPhase proc_exist.wait status = proc_exist.status if status == 1 then - modelbuilder.error(nat, "Error: package \"{pkg}\" unknown by pkg-config, make sure the development package is be installed.") + modelbuilder.error(nat, "Error: package `{pkg}` unknown by `pkg-config`, make sure the development package is be installed.") return else if status != 0 then - modelbuilder.error(nat, "Error: something went wrong calling pkg-config, make sure it is correctly installed.") + modelbuilder.error(nat, "Error: something went wrong calling `pkg-config`, make sure it is correctly installed.") return end diff --git a/src/frontend/check_annotation.nit b/src/frontend/check_annotation.nit index ffba4ad..6d9bb60 100644 --- a/src/frontend/check_annotation.nit +++ b/src/frontend/check_annotation.nit @@ -61,7 +61,7 @@ private class CheckAnnotationPhase for m in super_mmodules do if declared_annotations[m].has(name) then - modelbuilder.warning(annot, "multiple-annotation-declarations", "Warning: an annotation `{name}` is already declared in module `{m}`") + modelbuilder.warning(annot, "multiple-annotation-declarations", "Warning: an annotation `{name}` is already declared in module `{m}`.") break label end end @@ -125,7 +125,7 @@ platform if annots.has(name) then return - toolcontext.modelbuilder.warning(nat, "unknown-annotation", "Warning: unknown annotation `{name}`") + toolcontext.modelbuilder.warning(nat, "unknown-annotation", "Warning: unknown annotation `{name}`.") annots.add(name) # to avoid multiple errors on the same name end diff --git a/src/frontend/deriving.nit b/src/frontend/deriving.nit index 955e24a..3cd8718 100644 --- a/src/frontend/deriving.nit +++ b/src/frontend/deriving.nit @@ -37,7 +37,7 @@ private class DerivingPhase do if nat.name == "auto_inspect" then if not nclassdef isa AStdClassdef then - toolcontext.error(nclassdef.location, "Syntax error: only a concrete class can be `{nat.name}`.") + toolcontext.error(nclassdef.location, "Syntax Error: only a concrete class can be `{nat.name}`.") else generate_inspect_method(nclassdef) end @@ -45,7 +45,7 @@ private class DerivingPhase if nat.name == "auto_derive" then if not nclassdef isa AStdClassdef then - toolcontext.error(nclassdef.location, "Syntax error: only a concrete class can be `{nat.name}`.") + toolcontext.error(nclassdef.location, "Syntax Error: only a concrete class can be `{nat.name}`.") else generate_derive_to_map_method(nclassdef, nat) end diff --git a/src/frontend/div_by_zero.nit b/src/frontend/div_by_zero.nit index 6001f01..1e187e2 100644 --- a/src/frontend/div_by_zero.nit +++ b/src/frontend/div_by_zero.nit @@ -80,6 +80,6 @@ private class DivByZeroVisitor if not op1.mtype.is_subtype(mmodule, null, int_type) then return # Error detected - toolcontext.error(node.location, "Error: Definitely division by zero") + toolcontext.warning(node.location, "div-by-zero", "Warning: division by zero.") end end diff --git a/src/frontend/glsl_validation.nit b/src/frontend/glsl_validation.nit index 692d918..6d67d2c 100644 --- a/src/frontend/glsl_validation.nit +++ b/src/frontend/glsl_validation.nit @@ -52,7 +52,7 @@ private class GLSLValidationPhase # Only applicable on strings if not nstring isa AStringFormExpr then toolcontext.error(nstring.location, - "Syntax error: only a string literal can be annotated as \"{annot_name}\".") + "Syntax Error: only a string literal can be annotated as `{annot_name}`.") return end @@ -70,7 +70,7 @@ private class GLSLValidationPhase tool_is_in_path = in_path if not in_path then toolcontext.warning(nat.location, "glslvalidator", - "Warning: program \"glslangValidator\" not in PATH, cannot validate this shader.") + "Warning: program `glslangValidator` not in PATH, cannot validate this shader.") return end end diff --git a/src/frontend/no_warning.nit b/src/frontend/no_warning.nit index bc59d8c..b3cfd30 100644 --- a/src/frontend/no_warning.nit +++ b/src/frontend/no_warning.nit @@ -58,20 +58,20 @@ private class NoWarningPhase if annots.is_empty then return if source == null then - modelbuilder.warning(annots.first, "file-less-module", "Warning: annotation `{name}` does not currently work on file-less modules.") + modelbuilder.warning(annots.first, "file-less-module", "Warning: `{name}` does not currently work on file-less modules.") return end for annot in annots do var args = annot.n_args if args.is_empty then - modelbuilder.error(annot, "Annotation error: `{name}` needs a list of warnings. Use `\"all\"` to disable all warnings.") + modelbuilder.error(annot, "Syntax Error: `{name}` expects a list of warnings. Use `\"all\"` to disable all warnings.") continue end for arg in args do var tag = arg.as_string if tag == null then - modelbuilder.error(arg, "Annotation error: `{name}` expects String as arguments.") + modelbuilder.error(arg, "Syntax Error: `{name}` expects String as arguments.") continue end diff --git a/src/frontend/parallelization_phase.nit b/src/frontend/parallelization_phase.nit index 8cd7965..2d15d82 100644 --- a/src/frontend/parallelization_phase.nit +++ b/src/frontend/parallelization_phase.nit @@ -36,14 +36,14 @@ private class ParallelizationPhase if nat.n_atid.n_id.text != "threaded" then return if not nmethdef isa AMethPropdef then - toolcontext.error(nmethdef.location, "Syntax error: only a method can be threaded.") + toolcontext.error(nat.location, "Syntax Error: only a method can be threaded.") return end #TODO: check for self calls if nmethdef.n_signature.n_type != null then - toolcontext.error(nmethdef.location, "Syntax error: method with a return value not supported yet.") + toolcontext.error(nat.location, "Error: functions not supported yet.") return end diff --git a/src/frontend/serialization_phase.nit b/src/frontend/serialization_phase.nit index 0d7e4ec..976d532 100644 --- a/src/frontend/serialization_phase.nit +++ b/src/frontend/serialization_phase.nit @@ -43,7 +43,7 @@ private class SerializationPhasePreModel # Skip if we are not interested if nat.n_atid.n_id.text != "auto_serializable" then return if not nclassdef isa AStdClassdef then - toolcontext.error(nclassdef.location, "Syntax error: only a concrete class can be automatically serialized.") + toolcontext.error(nclassdef.location, "Syntax Error: only a concrete class can be automatically serialized.") return end @@ -153,7 +153,7 @@ private class SerializationPhasePreModel code.add " redef fun deserialize_class(name)" code.add " do" else - toolcontext.error(deserializer_npropdef.location, "Annotation error: you cannot define Deserializer::deserialize_class in a module where you use \"auto_serializable\".") + toolcontext.error(deserializer_npropdef.location, "Error: you cannot define `Deserializer::deserialize_class` in a module where you use `auto_serializable`.") return end diff --git a/src/literal.nit b/src/literal.nit index bc361ab..d6cb84e 100644 --- a/src/literal.nit +++ b/src/literal.nit @@ -123,7 +123,7 @@ redef class ACharExpr do var txt = self.n_char.text.unescape_nit if txt.length != 3 then - v.toolcontext.error(self.hot_location, "Invalid character literal {txt}") + v.toolcontext.error(self.hot_location, "Syntax Error: invalid character literal `{txt}`.") return end self.value = txt.chars[1] diff --git a/src/loader.nit b/src/loader.nit index 9876bc4..0e6878b 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -245,9 +245,9 @@ redef class ModelBuilder if candidate == null then if mgroup != null then - error(anode, "Error: cannot find module {name} from {mgroup.name}. tried {lookpaths.join(", ")}") + error(anode, "Error: cannot find module `{name}` from `{mgroup.name}`. Tried: {lookpaths.join(", ")}.") else - error(anode, "Error: cannot find module {name}. tried {lookpaths.join(", ")}") + error(anode, "Error: cannot find module `{name}`. Tried: {lookpaths.join(", ")}.") end return null end @@ -284,7 +284,7 @@ redef class ModelBuilder var abs_candidate = module_absolute_path(candidate) var abs_try_file = module_absolute_path(try_file) if abs_candidate != abs_try_file then - toolcontext.error(location, "Error: conflicting module file for {name}: {candidate} {try_file}") + toolcontext.error(location, "Error: conflicting module file for `{name}`: `{candidate}` `{try_file}`") end end end @@ -297,7 +297,7 @@ redef class ModelBuilder var abs_candidate = module_absolute_path(candidate) var abs_try_file = module_absolute_path(try_file) if abs_candidate != abs_try_file then - toolcontext.error(location, "Error: conflicting module file for {name}: {candidate} {try_file}") + toolcontext.error(location, "Error: conflicting module file for `{name}`: `{candidate}` `{try_file}`") end end end @@ -485,11 +485,11 @@ redef class ModelBuilder fun load_module_ast(filename: String): nullable AModule do if filename.file_extension != "nit" then - self.toolcontext.error(null, "Error: file {filename} is not a valid nit module.") + self.toolcontext.error(null, "Error: file `{filename}` is not a valid nit module.") return null end if not filename.file_exists then - self.toolcontext.error(null, "Error: file {filename} not found.") + self.toolcontext.error(null, "Error: file `{filename}` not found.") return null end @@ -607,7 +607,7 @@ redef class ModelBuilder if decl != null then var decl_name = decl.n_name.n_id.text if decl_name != mod_name then - error(decl.n_name, "Error: module name missmatch; declared {decl_name} file named {mod_name}") + error(decl.n_name, "Error: module name mismatch; declared {decl_name} file named {mod_name}.") end end @@ -618,7 +618,7 @@ redef class ModelBuilder if other.mgroup!= null and other.mgroup.mproject == mgroup.mproject then var node: ANode if decl == null then node = nmodule else node = decl.n_name - error(node, "Error: A module named `{other.full_name}` already exists at {other.location}") + error(node, "Error: a module named `{other.full_name}` already exists at {other.location}.") break end end @@ -693,11 +693,11 @@ redef class ModelBuilder return end if sup == mmodule then - error(aimport.n_name, "Error: Dependency loop in module {mmodule}.") + error(aimport.n_name, "Error: dependency loop in module {mmodule}.") nmodule.mmodule = null # invalidate the module end if sup.in_importation < mmodule then - error(aimport.n_name, "Error: Dependency loop between modules {mmodule} and {sup}.") + error(aimport.n_name, "Error: dependency loop between modules {mmodule} and {sup}.") nmodule.mmodule = null # invalidate the module return end diff --git a/src/metrics/detect_covariance.nit b/src/metrics/detect_covariance.nit index 9090658..4a3437d 100644 --- a/src/metrics/detect_covariance.nit +++ b/src/metrics/detect_covariance.nit @@ -371,7 +371,7 @@ redef class TypeVisitor dcp.cpt_autocast.inc("vt+pt") dcp.count_cast(node, supx, sub, mmodule, anchor) else - self.modelbuilder.error(node, "Type error: expected {sup}, got {sub}") + self.modelbuilder.error(node, "Type Error: expected `{sup}`, got `{sub}`") return null end end diff --git a/src/mixin.nit b/src/mixin.nit index 1ee4109..d70313d 100644 --- a/src/mixin.nit +++ b/src/mixin.nit @@ -64,13 +64,13 @@ redef class ToolContext if spl.length > 1 then val = spl[1] var prop = mainmodule.try_get_primitive_method(name, recv.mclass) if prop == null then - error(null, "Error: --define: no top-level function `{name}`") + error(null, "Error: --define: no top-level function `{name}`.") continue end var ret = prop.intro.msignature.return_mtype var v if ret == null then - error(null, "Error: --define: Method `{prop}` is not a function") + error(null, "Error: --define: method `{prop}` is not a function.") continue else if ret.to_s == "Bool" then if val == null or val == "true" then @@ -78,25 +78,25 @@ redef class ToolContext else if val == "false" then v = false else - error(null, "Error: --define: Method `{prop}` need a Bool.") + error(null, "Error: --define: method `{prop}` needs a Bool.") continue end else if ret.to_s == "Int" then if val != null and val.is_numeric then v = val.to_i else - error(null, "Error: --define: Method `{prop}` need a Int.") + error(null, "Error: --define: method `{prop}` needs a Int.") continue end else if ret.to_s == "String" then if val != null then v = val else - error(null, "Error: --define: Method `{prop}` need a String.") + error(null, "Error: --define: method `{prop}` needs a String.") continue end else - error(null, "Error: --define: Method `{prop}` return an unmanaged type {ret}.") + error(null, "Error: --define: method `{prop}` returns an unsupported type `{ret}`.") continue end var pd = new MMethodDef(mclassdef, prop, location) diff --git a/src/modelbuilder_base.nit b/src/modelbuilder_base.nit index 93423df..8e1e7c6 100644 --- a/src/modelbuilder_base.nit +++ b/src/modelbuilder_base.nit @@ -74,7 +74,7 @@ class ModelBuilder if res == null then res = mclass else - error(anode, "Ambigous class name '{name}'; conflict between {mclass.full_name} and {res.full_name}") + error(anode, "Error: ambiguous class name `{name}`; conflict between `{mclass.full_name}` and `{res.full_name}`.") return null end end @@ -168,7 +168,7 @@ class ModelBuilder assert ress.length > 1 var s = new Array[String] for mprop in ress do s.add mprop.full_name - self.error(anode, "Ambigous property name '{name}' for {mtype}; conflict between {s.join(" and ")}") + self.error(anode, "Error: ambiguous property name `{name}` for `{mtype}`; conflict between {s.join(" and ")}.") end self.try_get_mproperty_by_name2_cache[mmodule, mtype, name] = res @@ -218,7 +218,7 @@ class ModelBuilder if res == null then var l = null if n != null then l = n.hot_location - self.toolcontext.fatal_error(l, "Fatal Error: {recv} must have a property named {name}.") + self.toolcontext.fatal_error(l, "Fatal Error: `{recv}` must have a property named `{name}`.") abort end return res @@ -238,7 +238,7 @@ class ModelBuilder var prop = try_get_mproperty_by_name(ntype, mclassdef, name).as(nullable MVirtualTypeProp) if prop != null then if not ntype.n_types.is_empty then - error(ntype, "Type error: formal type {name} cannot have formal parameters.") + error(ntype, "Type Error: formal type `{name}` cannot have formal parameters.") end res = prop.mvirtualtype if ntype.n_kwnullable != null then res = res.as_nullable @@ -253,7 +253,7 @@ class ModelBuilder if p.name != name then continue if not ntype.n_types.is_empty then - error(ntype, "Type error: formal type {name} cannot have formal parameters.") + error(ntype, "Type Error: formal type `{name}` cannot have formal parameters.") end res = p @@ -269,11 +269,11 @@ class ModelBuilder var arity = ntype.n_types.length if arity != mclass.arity then if arity == 0 then - error(ntype, "Type error: '{name}' is a generic class.") + error(ntype, "Type Error: `{mclass.signature_to_s}` is a generic class.") else if mclass.arity == 0 then - error(ntype, "Type error: '{name}' is not a generic class.") + error(ntype, "Type Error: `{name}` is not a generic class.") else - error(ntype, "Type error: '{name}' has {mclass.arity} parameters ({arity} are provided).") + error(ntype, "Type Error: expected {mclass.arity} formal argument(s) for `{mclass.signature_to_s}`; got {arity}.") end return null end @@ -297,7 +297,7 @@ class ModelBuilder end # If everything fail, then give up :( - error(ntype, "Type error: class {name} not found in module {mmodule}.") + error(ntype, "Error: class `{name}` not found in module `{mmodule}`.") return null end @@ -324,7 +324,7 @@ class ModelBuilder var anchor if mclassdef != null then anchor = mclassdef.bound_mtype else anchor = null if not check_subtype(nt, mmodule, anchor, mt, bound) then - error(nt, "Type error: expected {bound}, got {mt}") + error(nt, "Type Error: expected `{bound}`, got `{mt}`.") return null end end diff --git a/src/modelize/modelize_class.nit b/src/modelize/modelize_class.nit index ae4e4c2..3503bd0 100644 --- a/src/modelize/modelize_class.nit +++ b/src/modelize/modelize_class.nit @@ -65,11 +65,11 @@ redef class ModelBuilder var nfd = nclassdef.n_formaldefs[i] var ptname = nfd.n_id.text if names.has(ptname) then - error(nfd, "Error: A formal parameter type `{ptname}' already exists") + error(nfd, "Error: a formal parameter type `{ptname}` already exists.") return end for c in ptname.chars do if c >= 'a' and c<= 'z' then - warning(nfd, "formal-type-name", "Warning: lowercase in the formal parameter type {ptname}") + warning(nfd, "formal-type-name", "Warning: lowercase in the formal parameter type `{ptname}`.") break end names.add(ptname) @@ -95,7 +95,7 @@ redef class ModelBuilder var mclass = try_get_mclass_by_name(nclassdef, mmodule, name) if mclass == null then if nclassdef isa AStdClassdef and nclassdef.n_kwredef != null then - error(nclassdef, "Redef error: No imported class {name} to refine.") + error(nclassdef, "Redef Error: no imported class `{name}` to refine.") return end @@ -106,7 +106,7 @@ redef class ModelBuilder if other.intro_mmodule.mgroup != null and other.intro_mmodule.mgroup.mproject == mmodule.mgroup.mproject then # Skip classes that are buggy if other.try_intro == null then continue - warning(nclassdef, "full-name-conflict", "Error: A class named `{other.full_name}` is already defined in module `{other.intro_mmodule}` at {other.intro.location}.") + warning(nclassdef, "full-name-conflict", "Error: a class named `{other.full_name}` is already defined in module `{other.intro_mmodule}` at {other.intro.location}.") break end end @@ -115,18 +115,18 @@ redef class ModelBuilder mclass = new MClass(mmodule, name, names, mkind, mvisibility) #print "new class {mclass}" else if nclassdef isa AStdClassdef and nmodule.mclass2nclassdef.has_key(mclass) then - error(nclassdef, "Error: A class {name} is already defined at line {nmodule.mclass2nclassdef[mclass].location.line_start}.") + error(nclassdef, "Error: a class `{name}` is already defined at line {nmodule.mclass2nclassdef[mclass].location.line_start}.") return else if nclassdef isa AStdClassdef and nclassdef.n_kwredef == null then - error(nclassdef, "Redef error: {name} is an imported class. Add the redef keyword to refine it.") + error(nclassdef, "Redef Error: `{name}` is an imported class. Add the `redef` keyword to refine it.") return else if arity != 0 and mclass.arity != arity then - error(nclassdef, "Redef error: Formal parameter arity missmatch; got {arity}, expected {mclass.arity}.") + error(nclassdef, "Redef Error: expected {mclass.arity} formal parameter(s) for {mclass.signature_to_s}; got {arity}.") return else if nkind != null and mkind != concrete_kind and mclass.kind != mkind then - error(nkind, "Error: refinement changed the kind from a {mclass.kind} to a {mkind}") + error(nkind, "Redef Error: refinement changed the kind from `{mclass.kind}` to `{mkind}`.") else if nvisibility != null and mvisibility != public_visibility and mclass.visibility != mvisibility then - error(nvisibility, "Error: refinement changed the visibility from a {mclass.visibility} to a {mvisibility}") + error(nvisibility, "Redef Error: refinement changed the visibility from `{mclass.visibility}` to `{mvisibility}`") end nclassdef.mclass = mclass if not nmodule.mclass2nclassdef.has_key(mclass) then @@ -167,7 +167,7 @@ redef class ModelBuilder var nfd = nclassdef.n_formaldefs[i] var pname = mclass.mparameters[i].name if nfd.n_id.text != pname then - error(nfd.n_id, "Error: Formal parameter type #{i} `{nfd.n_id.text}` must be named `{pname}' as in the original definition in module `{mclass.intro.mmodule}`.") + error(nfd.n_id, "Error: formal parameter type #{i} `{nfd.n_id.text}` must be named `{pname}` as in the original definition in module `{mclass.intro.mmodule}`.") end var nfdt = nfd.n_type if nfdt != null then @@ -175,17 +175,17 @@ redef class ModelBuilder if bound == null then return # Forward error if bound.need_anchor then # No F-bounds! - error(nfd, "Error: Formal parameter type `{pname}' bounded with a formal parameter type") + error(nfd, "Error: formal parameter type `{pname}` bounded with a formal parameter type.") else bounds.add(bound) nfd.bound = bound end if bound isa MClassType and bound.mclass.kind == enum_kind then - warning(nfdt, "useless-bound", "Warning: Useless formal parameter type since `{bound}` cannnot have subclasses.") + warning(nfdt, "useless-bound", "Warning: useless formal parameter type since `{bound}` cannot have subclasses.") end else if mclass.mclassdefs.is_empty then if objectclass == null then - error(nfd, "Error: Formal parameter type `{pname}' unbounded but no Object class exist.") + error(nfd, "Error: formal parameter type `{pname}` unbounded but no `Object` class exists.") return end # No bound, then implicitely bound by nullable Object @@ -251,11 +251,11 @@ redef class ModelBuilder var mtype = resolve_mtype_unchecked(mmodule, mclassdef, ntype, false) if mtype == null then continue # Skip because of error if not mtype isa MClassType then - error(ntype, "Error: supertypes cannot be a formal type") + error(ntype, "Error: supertypes cannot be a formal type.") return end if not mclass.kind.can_specialize(mtype.mclass.kind) then - error(ntype, "Error: {mclass.kind} {mclass} cannot specialize {mtype.mclass.kind} {mtype.mclass}") + error(ntype, "Error: {mclass.kind} `{mclass}` cannot specialize {mtype.mclass.kind} `{mtype.mclass}`.") end supertypes.add mtype #print "new super : {mclass} < {mtype}" @@ -289,7 +289,7 @@ redef class ModelBuilder for s in mclassdef.supertypes do if s.is_subtype(mmodule, mclassdef.bound_mtype, mclassdef.bound_mtype) then - error(nclassdef, "Error: Inheritance loop for class {mclass} with type {s}") + error(nclassdef, "Error: inheritance loop for class `{mclass}` with type `{s}`.") end end end @@ -395,7 +395,7 @@ redef class ModelBuilder var st1 = superclasses[st.mclass].resolve_for(mclassdef.mclass.mclass_type, mclassdef.bound_mtype, mmodule, false) var st2 = st.resolve_for(mclassdef.mclass.mclass_type, mclassdef.bound_mtype, mmodule, false) if st1 != st2 then - error(nclassdef, "Error: Incompatibles ancestors for {mclassdef.mclass}: {st1}, {st2}") + error(nclassdef, "Error: incompatible ancestors for `{mclassdef.mclass}`; conflict: `{st1}` and `{st2}`") end end end @@ -435,12 +435,12 @@ redef class ModelBuilder if not parents.has(sc) or sc == objectclass then # Skip the warning on generated code if ntype.location.file != null and not ntype.location.file.filename.is_empty then - warning(ntype, "useless-superclass", "Warning: superfluous super-class {mtype} in class {mclassdef.mclass}.") + warning(ntype, "useless-superclass", "Warning: superfluous super-class `{mtype}` in class `{mclassdef.mclass}`.") end else if not seen_parents.has_key(sc) then seen_parents[sc] = ntype else - warning(ntype, "useless-superclass", "Warning: duplicated super-class {mtype} in class {mclassdef.mclass}.") + warning(ntype, "useless-superclass", "Warning: duplicated super-class `{mtype}` in class `{mclassdef.mclass}`.") end end end diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index d4a5654..26b2f05 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -190,7 +190,7 @@ redef class ModelBuilder if sig == null then continue # Skip broken method if not npropdef.mpropdef.is_intro then - self.error(at, "Error: `autoinit` cannot be set on redefinitions") + self.error(at, "Error: `autoinit` cannot be set on redefinitions.") continue end @@ -237,7 +237,7 @@ redef class ModelBuilder # Look for most-specific new-stype init definitions var spropdefs = the_root_init_mmethod.lookup_super_definitions(mclassdef.mmodule, mclassdef.bound_mtype) if spropdefs.is_empty then - toolcontext.error(nclassdef.location, "Error: {mclassdef} does not specialize {the_root_init_mmethod.intro_mclassdef}. Possible duplication of the root class `Object`?") + toolcontext.error(nclassdef.location, "Error: `{mclassdef}` does not specialize `{the_root_init_mmethod.intro_mclassdef}`. Possible duplication of the root class `Object`?") return end @@ -254,14 +254,14 @@ redef class ModelBuilder end if autoinit.n_args.is_empty then - error(autoinit, "Syntax error: `autoinit` expects method identifiers, use `noautoinit` to clear all autoinits.") + error(autoinit, "Syntax Error: `autoinit` expects method identifiers, use `noautoinit` to clear all autoinits.") end # Get and check each argument for narg in autoinit.n_args do var id = narg.as_id if id == null then - error(narg, "Syntax error: `autoinit` expects method identifiers.") + error(narg, "Syntax Error: `autoinit` expects method identifiers.") return end @@ -390,10 +390,10 @@ redef class ModelBuilder assert mmodule_type != null var vis_module_type = mmodule.visibility_for(mmodule_type) # the visibility of the original module if mproperty.visibility > vis_type then - error(node, "Error: The {mproperty.visibility} property `{mproperty}` cannot contain the {vis_type} type `{mtype}`") + error(node, "Error: the {mproperty.visibility} property `{mproperty}` cannot contain the {vis_type} type `{mtype}`.") return else if mproperty.visibility > vis_module_type then - error(node, "Error: The {mproperty.visibility} property `{mproperty}` cannot contain the type `{mtype}` from the {vis_module_type} module `{mmodule_type}`") + error(node, "Error: the {mproperty.visibility} property `{mproperty}` cannot contain the type `{mtype}` from the {vis_module_type} module `{mmodule_type}`.") return end end @@ -462,9 +462,9 @@ redef class ModelBuilder for next in nexts do if poset.has_edge(next, t) then if mtype == next then - error(node, "Error: circularity of virtual type definition: {next} <-> {t}") + error(node, "Error: circularity of virtual type definition: {next} <-> {t}.") else - error(node, "Error: circularity of virtual type definition: {mtype} -> {next} <-> {t}") + error(node, "Error: circularity of virtual type definition: {mtype} -> {next} <-> {t}.") end return false else @@ -527,17 +527,17 @@ redef class MClassDef # SELF must be declared in Object, otherwise this will create conflicts if intro_mclassdef.mclass.name != "Object" then - modelbuilder.error(nintro, "Error: the virtual type SELF must be declared in Object.") + modelbuilder.error(nintro, "Error: the virtual type `SELF` must be declared in `Object`.") end # SELF must be public if mprop.visibility != public_visibility then - modelbuilder.error(nintro, "Error: the virtual type SELF must be public.") + modelbuilder.error(nintro, "Error: the virtual type `SELF` must be public.") end # SELF must not be fixed if intro.is_fixed then - modelbuilder.error(nintro, "Error: the virtual type SELF cannot be fixed.") + modelbuilder.error(nintro, "Error: the virtual type `SELF` cannot be fixed.") end return @@ -566,17 +566,17 @@ redef class APropdef if nvisibility != null then mvisibility = nvisibility.mvisibility if mvisibility == intrude_visibility then - modelbuilder.error(nvisibility, "Error: intrude is not a legal visibility for properties.") + modelbuilder.error(nvisibility, "Error: `intrude` is not a legal visibility for properties.") mvisibility = public_visibility end end if mclassdef.mclass.visibility == private_visibility then if mvisibility == protected_visibility then assert nvisibility != null - modelbuilder.error(nvisibility, "Error: The only legal visibility for properties in a private class is private.") + modelbuilder.error(nvisibility, "Error: `private` is the only legal visibility for properties in a private class.") else if mvisibility == private_visibility then assert nvisibility != null - modelbuilder.advice(nvisibility, "useless-visibility", "Warning: private is superfluous since the only legal visibility for properties in a private class is private.") + modelbuilder.advice(nvisibility, "useless-visibility", "Warning: `private` is superfluous since the only legal visibility for properties in a private class is private.") end mvisibility = private_visibility end @@ -612,20 +612,20 @@ redef class APropdef if nvisibility == null then return var mvisibility = nvisibility.mvisibility if mvisibility != mprop.visibility and mvisibility != public_visibility then - modelbuilder.error(nvisibility, "Error: redefinition changed the visibility from a {mprop.visibility} to a {mvisibility}") + modelbuilder.error(nvisibility, "Error: redefinition changed the visibility from `{mprop.visibility}` to `{mvisibility}`.") end end private fun check_redef_keyword(modelbuilder: ModelBuilder, mclassdef: MClassDef, kwredef: nullable Token, need_redef: Bool, mprop: MProperty): Bool do if mclassdef.mprop2npropdef.has_key(mprop) then - modelbuilder.error(self, "Error: A property {mprop} is already defined in class {mclassdef.mclass} at line {mclassdef.mprop2npropdef[mprop].location.line_start}.") + modelbuilder.error(self, "Error: a property `{mprop}` is already defined in class `{mclassdef.mclass}` at line {mclassdef.mprop2npropdef[mprop].location.line_start}.") return false end if mprop isa MMethod and mprop.is_root_init then return true if kwredef == null then if need_redef then - modelbuilder.error(self, "Redef error: {mclassdef.mclass}::{mprop.name} is an inherited property. To redefine it, add the redef keyword.") + modelbuilder.error(self, "Redef Error: `{mclassdef.mclass}::{mprop.name}` is an inherited property. To redefine it, add the `redef` keyword.") return false end @@ -642,7 +642,7 @@ redef class APropdef end else if not need_redef then - modelbuilder.error(self, "Error: No property {mclassdef.mclass}::{mprop.name} is inherited. Remove the redef keyword to define a new property.") + modelbuilder.error(self, "Error: no property `{mclassdef.mclass}::{mprop.name}` is inherited. Remove the `redef` keyword to define a new property.") return false end end @@ -683,7 +683,7 @@ redef class ASignature end if np.n_dotdotdot != null then if self.vararg_rank != -1 then - modelbuilder.error(np, "Error: {param_names[self.vararg_rank]} is already a vararg") + modelbuilder.error(np, "Error: `{param_names[self.vararg_rank]}` is already a vararg") return false else self.vararg_rank = param_names.length - 1 @@ -892,7 +892,7 @@ redef class AMethPropdef if param_names.length != msignature.arity then var node: ANode if nsig != null then node = nsig else node = self - modelbuilder.error(node, "Redef error: {mpropdef} redefines {mpropdef.mproperty.intro} with {param_names.length} parameter(s), {msignature.arity} expected. Signature is {mpropdef}{msignature}") + modelbuilder.error(node, "Redef Error: expected {msignature.arity} parameter(s) for `{mpropdef.mproperty.name}{msignature}`; got {param_names.length}. See introduction at `{mpropdef.mproperty.full_name}`.") return end else if mpropdef.mproperty.is_init and not mpropdef.mproperty.is_new then @@ -924,7 +924,7 @@ redef class AMethPropdef if param_names.length != param_types.length then # Some parameters are typed, other parameters are not typed. - modelbuilder.error(nsig.n_params[param_types.length], "Error: Untyped parameter `{param_names[param_types.length]}'.") + modelbuilder.error(nsig.n_params[param_types.length], "Error: untyped parameter `{param_names[param_types.length]}'.") return end @@ -946,7 +946,7 @@ redef class AMethPropdef # Check annotations var at = self.get_single_annotation("lazy", modelbuilder) - if at != null then modelbuilder.error(at, "Syntax error: `lazy` must be used on attributes.") + if at != null then modelbuilder.error(at, "Syntax Error: `lazy` must be used on attributes.") end redef fun check_signature(modelbuilder) @@ -976,7 +976,7 @@ redef class AMethPropdef var precursor_ret_type = msignature.return_mtype var ret_type = mysignature.return_mtype if ret_type != null and precursor_ret_type == null then - modelbuilder.error(nsig.n_type.as(not null), "Redef Error: {mpropdef.mproperty} is a procedure, not a function.") + modelbuilder.error(nsig.n_type.as(not null), "Redef Error: `{mpropdef.mproperty}` is a procedure, not a function.") self.mpropdef.msignature = null return end @@ -988,7 +988,7 @@ redef class AMethPropdef var prt = msignature.mparameters[i].mtype var node = nsig.n_params[i] if not modelbuilder.check_sametype(node, mmodule, mclassdef.bound_mtype, myt, prt) then - modelbuilder.error(node, "Redef Error: Wrong type for parameter `{mysignature.mparameters[i].name}'. found {myt}, expected {prt} as in {mpropdef.mproperty.intro}.") + modelbuilder.error(node, "Redef Error: expected `{prt}` for parameter `{mysignature.mparameters[i].name}'; got `{myt}`.") self.mpropdef.msignature = null end end @@ -1001,7 +1001,7 @@ redef class AMethPropdef # Inherit the return type ret_type = precursor_ret_type else if not modelbuilder.check_subtype(node, mmodule, mclassdef.bound_mtype, ret_type, precursor_ret_type) then - modelbuilder.error(node, "Redef Error: Wrong return type. found {ret_type}, expected {precursor_ret_type} as in {mpropdef.mproperty.intro}.") + modelbuilder.error(node, "Redef Error: expected `{precursor_ret_type}` for return type; got `{ret_type}`.") self.mpropdef.msignature = null end end @@ -1051,12 +1051,8 @@ redef class AAttrPropdef var atabstract = self.get_single_annotation("abstract", modelbuilder) if atabstract == null then - if mclass.kind == interface_kind then - modelbuilder.error(self, "Error: Attempt to define attribute {name} in the interface {mclass}.") - else if mclass.kind == enum_kind then - modelbuilder.error(self, "Error: Attempt to define attribute {name} in the enum class {mclass}.") - else if mclass.kind == extern_kind then - modelbuilder.error(self, "Error: Attempt to define attribute {name} in the extern class {mclass}.") + if not mclass.kind.need_init then + modelbuilder.error(self, "Error: attempt to define attribute `{name}` in the {mclass.kind} `{mclass}`.") end var mprop = new MAttribute(mclassdef, "_" + name, private_visibility) @@ -1087,7 +1083,7 @@ redef class AAttrPropdef has_value = n_expr != null or n_block != null if atabstract != null and has_value then - modelbuilder.error(atabstract, "Error: `abstract` attributes cannot have an initial value") + modelbuilder.error(atabstract, "Error: `abstract` attributes cannot have an initial value.") return end @@ -1096,11 +1092,11 @@ redef class AAttrPropdef if atnoinit != null then noinit = true if has_value then - modelbuilder.error(atnoinit, "Error: `noautoinit` attributes cannot have an initial value") + modelbuilder.error(atnoinit, "Error: `noautoinit` attributes cannot have an initial value.") return end if atabstract != null then - modelbuilder.error(atnoinit, "Error: `noautoinit` attributes cannot be abstract") + modelbuilder.error(atnoinit, "Error: `noautoinit` attributes cannot be abstract.") return end end @@ -1109,14 +1105,14 @@ redef class AAttrPropdef var atautoinit = self.get_single_annotation("autoinit", modelbuilder) if atlazy != null or atautoinit != null then if atlazy != null and atautoinit != null then - modelbuilder.error(atlazy, "Error: lazy incompatible with autoinit") + modelbuilder.error(atlazy, "Error: `lazy` incompatible with `autoinit`.") return end if not has_value then if atlazy != null then - modelbuilder.error(atlazy, "Error: a lazy attribute needs a value") + modelbuilder.error(atlazy, "Error: `lazy` attributes need a value.") else if atautoinit != null then - modelbuilder.error(atautoinit, "Error: a autoinit attribute needs a value") + modelbuilder.error(atautoinit, "Error: `autoinit` attributes need a value.") end has_value = true return @@ -1130,7 +1126,7 @@ redef class AAttrPropdef var atreadonly = self.get_single_annotation("readonly", modelbuilder) if atreadonly != null then if not has_value then - modelbuilder.error(atreadonly, "Error: a readonly attribute needs a value") + modelbuilder.error(atreadonly, "Error: `readonly` attributes need a value.") end # No setter, so just leave return @@ -1224,7 +1220,7 @@ redef class AAttrPropdef var cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "String") if cla != null then mtype = cla.mclass_type else - modelbuilder.error(self, "Error: Untyped attribute {mreadpropdef}. Implicit typing allowed only for literals and new.") + modelbuilder.error(self, "Error: untyped attribute `{mreadpropdef}`. Implicit typing allowed only for literals and new.") end if mtype == null then return @@ -1239,7 +1235,7 @@ redef class AAttrPropdef end if mtype == null then - modelbuilder.error(self, "Error: Untyped attribute {mreadpropdef}") + modelbuilder.error(self, "Error: untyped attribute `{mreadpropdef}`.") return end @@ -1294,7 +1290,7 @@ redef class AAttrPropdef if precursor_type == null then return if mtype != precursor_type then - modelbuilder.error(ntype.as(not null), "Redef Error: Wrong static type. found {mtype}, expected {precursor_type}.") + modelbuilder.error(ntype.as(not null), "Redef Error: expected `{precursor_type}` type as a bound; got `{mtype}`.") return end end @@ -1333,7 +1329,7 @@ redef class AAttrPropdef if mysignature.arity != msignature.arity then var node: ANode if nsig != null then node = nsig else node = self - modelbuilder.error(node, "Redef Error: {mysignature.arity} parameters found, {msignature.arity} expected. Signature is {mpropdef}{msignature}") + modelbuilder.error(node, "Redef Error: expected {msignature.arity} parameter(s) for `{mpropdef.mproperty.name}{msignature}`; got {mysignature.arity}. See introduction at `{mpropdef.mproperty.full_name}`.") return end var precursor_ret_type = msignature.return_mtype @@ -1341,7 +1337,7 @@ redef class AAttrPropdef if ret_type != null and precursor_ret_type == null then var node: ANode if nsig != null then node = nsig else node = self - modelbuilder.error(node, "Redef Error: {mpropdef.mproperty} is a procedure, not a function.") + modelbuilder.error(node, "Redef Error: `{mpropdef.mproperty}` is a procedure, not a function.") return end @@ -1353,7 +1349,7 @@ redef class AAttrPropdef var node: ANode if nsig != null then node = nsig else node = self if not modelbuilder.check_sametype(node, mmodule, mclassdef.bound_mtype, myt, prt) then - modelbuilder.error(node, "Redef Error: Wrong type for parameter `{mysignature.mparameters[i].name}'. found {myt}, expected {prt}.") + modelbuilder.error(node, "Redef Error: expected `{prt}` type for parameter `{mysignature.mparameters[i].name}'; got `{myt}`.") end end end @@ -1364,7 +1360,7 @@ redef class AAttrPropdef # Inherit the return type ret_type = precursor_ret_type else if not modelbuilder.check_subtype(node, mmodule, mclassdef.bound_mtype, ret_type, precursor_ret_type) then - modelbuilder.error(node, "Redef Error: Wrong return type. found {ret_type}, expected {precursor_ret_type}.") + modelbuilder.error(node, "Redef Error: expected `{precursor_ret_type}` return type; got `{ret_type}`.") end end end @@ -1382,7 +1378,7 @@ redef class ATypePropdef var mvisibility = new_property_visibility(modelbuilder, mclassdef, self.n_visibility) mprop = new MVirtualTypeProp(mclassdef, name, mvisibility) for c in name.chars do if c >= 'a' and c<= 'z' then - modelbuilder.warning(n_id, "bad-type-name", "Warning: lowercase in the virtual type {name}") + modelbuilder.warning(n_id, "bad-type-name", "Warning: lowercase in the virtual type `{name}`.") break end if not self.check_redef_keyword(modelbuilder, mclassdef, self.n_kwredef, false, mprop) then return @@ -1450,7 +1446,7 @@ redef class ATypePropdef var supbound = p.bound if supbound == null then break # broken super bound, skip error if p.is_fixed then - modelbuilder.error(self, "Redef Error: Virtual type {mpropdef.mproperty} is fixed in super-class {p.mclassdef.mclass}") + modelbuilder.error(self, "Redef Error: virtual type `{mpropdef.mproperty}` is fixed in super-class `{p.mclassdef.mclass}`.") break end if p.mclassdef.mclass == mclassdef.mclass then @@ -1459,7 +1455,7 @@ redef class ATypePropdef break end if not modelbuilder.check_subtype(n_type, mmodule, anchor, bound, supbound) then - modelbuilder.error(n_type, "Redef Error: Wrong bound type. Found {bound}, expected a subtype of {supbound}, as in {p}.") + modelbuilder.error(n_type, "Redef Error: expected `{supbound}` bound type; got `{bound}`.") break end end diff --git a/src/nitls.nit b/src/nitls.nit index 7ffc58c..8755bfe 100644 --- a/src/nitls.nit +++ b/src/nitls.nit @@ -129,7 +129,7 @@ end var sum = opt_tree.value.to_i + opt_source.value.to_i + opt_project.value.to_i if sum > 1 then - print "Error: options --tree, --source, and --project are exclusives." + print "Error: options --tree, --source, and --project are exclusive." print tc.tooldescription exit 1 end diff --git a/src/nitni/nitni_callbacks.nit b/src/nitni/nitni_callbacks.nit index 210a4b5..823f624 100644 --- a/src/nitni/nitni_callbacks.nit +++ b/src/nitni/nitni_callbacks.nit @@ -287,7 +287,7 @@ redef class ALocalPropExternCall mmodule, mclass_type, m_name ) if method == null then - toolcontext.error(location, "Local method {m_name} not found.") + toolcontext.error(location, "Error: local method `{m_name}` not found.") return end @@ -313,7 +313,7 @@ redef class AFullPropExternCall end if mtype isa MNullableType then - toolcontext.error(location, "Type {n_type.collect_text} is nullable and thus cannot be the receiver." ) + toolcontext.error(location, "Error: type `{n_type.collect_text}` is nullable and thus cannot be the receiver." ) return end @@ -322,7 +322,7 @@ redef class AFullPropExternCall mmodule, mtype, m_name ) if method == null then - toolcontext.error(location, "Method {m_name} not found in {n_type.collect_text}." ) + toolcontext.error(location, "Error: method `{m_name}` not found in `{n_type.collect_text}`." ) return end @@ -341,7 +341,7 @@ redef class AInitPropExternCall if mtype == null then return if not mtype isa MClassType then - toolcontext.error(location, "Type {n_type.collect_text} is not a class and thus cannot be used to instanciate a new instance." ) + toolcontext.error(location, "Error: type `{n_type.collect_text}` is not a class and thus cannot be used to instantiate a new instance." ) return end @@ -356,7 +356,7 @@ redef class AInitPropExternCall end if meth == null then - toolcontext.error(location, "Method {meth_name} not found in {n_type.collect_text}." ) + toolcontext.error(location, "Error: method `{meth_name}` not found in `{n_type.collect_text}`." ) return end diff --git a/src/nitserial.nit b/src/nitserial.nit index db70d4c..0b60a1b 100644 --- a/src/nitserial.nit +++ b/src/nitserial.nit @@ -18,7 +18,7 @@ # # Executing on the module `game_logic` will create the module `game_logic_serial` # in the local directory. Mixing the generated module to the main module with -# `nitg game_logic.nit -m game_logic_serial` will create a program supporting +# `nitc game_logic.nit -m game_logic_serial` will create a program supporting # deserialization of all generic types visible from the main module. # # Because the generation is limited to the visible types, a module author might want @@ -215,7 +215,7 @@ redef class Deserializer for mtype in rta.live_types do # We are only interested in instanciated generics, subtypes of Serializable - # and which are visibles. + # and which are visible. if mtype isa MGenericType and mtype.is_subtype(m, null, serializable_type) and mtype.is_visible_from(mmodule) and diff --git a/src/parser/lexer_work.nit b/src/parser/lexer_work.nit index fa7f18f..0f06bce 100644 --- a/src/parser/lexer_work.nit +++ b/src/parser/lexer_work.nit @@ -248,7 +248,7 @@ class Lexer var location = new Location(file, start_line + 1, start_line + 1, start_pos + 1, start_pos + 1) if sp > start_stream_pos then var text = string.substring(start_stream_pos, sp-start_stream_pos) - var token = new ALexerError.init_lexer_error("Syntax error: unknown token {text}.", location, text) + var token = new ALexerError.init_lexer_error("Syntax Error: unknown token `{text}`.", location, text) file.last_token = token return token else diff --git a/src/parser/parser_work.nit b/src/parser/parser_work.nit index 29588b4..c2eff11 100644 --- a/src/parser/parser_work.nit +++ b/src/parser/parser_work.nit @@ -146,7 +146,7 @@ class Parser else if action_type == 3 then # ERROR # skip injected tokens while not isset token._location do token = lexer.next - var node2 = new AParserError.init_parser_error("Syntax error: unexpected {token}.", token.location, token) + var node2 = new AParserError.init_parser_error("Syntax Error: unexpected {token}.", token.location, token) var node = new Start(null, node2) return node end diff --git a/src/parser_util.nit b/src/parser_util.nit index 1e11840..cd4f205 100644 --- a/src/parser_util.nit +++ b/src/parser_util.nit @@ -30,7 +30,7 @@ redef class ToolContext var eof = tree.n_eof if eof isa AError then - self.fatal_error(null, "Fatal Error: {eof.message}") + self.fatal_error(null, "Fatal Error: {eof.message}.") abort end return tree.n_base.as(not null) @@ -43,7 +43,7 @@ redef class ToolContext var nmodule = parse_module(string) var nclassdefs = nmodule.n_classdefs if nclassdefs.length != 1 then - self.fatal_error(null, "Fatal Error: not a classdef") + self.fatal_error(null, "Fatal Error: not a classdef.") abort end return nclassdefs.first @@ -57,7 +57,7 @@ redef class ToolContext var nclassdef = parse_classdef(mod_string) var npropdefs = nclassdef.n_propdefs if npropdefs.length != 1 then - self.fatal_error(null, "Fatal Error: not a propdef") + self.fatal_error(null, "Fatal Error: not a propdef.") abort end return npropdefs.first @@ -91,7 +91,7 @@ redef class ToolContext var nclassdef = parse_classdef(mod_string).as(AStdClassdef) var nsuperclasses = nclassdef.n_propdefs if nsuperclasses.length != 1 then - self.fatal_error(null, "Fatal Error: not a super class declaration") + self.fatal_error(null, "Fatal Error: not a super class declaration.") abort end return nsuperclasses.first diff --git a/src/platform/android.nit b/src/platform/android.nit index 404d780..2958c4b 100644 --- a/src/platform/android.nit +++ b/src/platform/android.nit @@ -342,8 +342,9 @@ $(call import-module,android/native_app_glue) var tsa_server= "TSA_SERVER".environ if key_alias.is_empty then - toolcontext.fatal_error(null, - "Fatal Error: the environment variable `KEY_ALIAS` must be set to use the `--release` option on Android projects.") + toolcontext.error(null, + "Error: the environment variable `KEY_ALIAS` must be set to use the `--release` option on Android projects.") + return end args = ["jarsigner", "-sigalg", "MD5withRSA", "-digestalg", "SHA1", apk_path, key_alias] diff --git a/src/platform/app_annotations.nit b/src/platform/app_annotations.nit index 67af354..62fbbb0 100644 --- a/src/platform/app_annotations.nit +++ b/src/platform/app_annotations.nit @@ -84,11 +84,11 @@ redef class AAnnotation var args = n_args if args.length < 1 then - modelbuilder.error(self, "Annotation error: \"{name}\" expects at least a single argument.") + modelbuilder.error(self, "Syntax Error: `{name}` expects at least one argument.") return "" else for arg in args do - var format_error = "Annotation error: \"{name}\" expects its arguments to be of type Int or a call to `git_revision`" + var format_error = "Syntax Eror: `{name}` expects its arguments to be of type Int or a call to `git_revision`." var value value = arg.as_int diff --git a/src/platform/platform.nit b/src/platform/platform.nit index 40069c4..8fafcd1 100644 --- a/src/platform/platform.nit +++ b/src/platform/platform.nit @@ -44,21 +44,21 @@ private class PlatformPhase # Do some validity checks and print errors if the annotation is used incorrectly var modelbuilder = toolcontext.modelbuilder if not nmoduledecl isa AModuledecl then - modelbuilder.error(nat, "Syntax error: only the declaration of modules may use \"{annotation_name}\".") + modelbuilder.error(nat, "Syntax Error: only the declaration of modules may use `{annotation_name}`.") return end var args = nat.n_args var platform_name if args.length > 1 then - modelbuilder.error(nat, "Syntax error: \"{annotation_name}\" expects at most a single argument.") + modelbuilder.error(nat, "Syntax Error: `{annotation_name}` expects at most a single argument.") return else if args.is_empty then platform_name = nmoduledecl.n_name.collect_text else platform_name = args.first.as_string if platform_name == null then - var format_error = "Syntax error: \"{annotation_name}\" expects its argument to be the name of the target platform as a String literal." + var format_error = "Syntax Error: `{annotation_name}` expects its argument to be the name of the target platform as a String literal." modelbuilder.error(nat, format_error) return end @@ -69,13 +69,13 @@ private class PlatformPhase var platform = toolcontext.platform_from_name(platform_name) if platform == null then - toolcontext.error(nat.location, "Error: target platform \"{platform_name}\" unknown") + toolcontext.error(nat.location, "Error: target platform `{platform_name}` unknown.") return end var previous_target_platform = mmodule.target_platform if previous_target_platform != null and previous_target_platform != platform then - modelbuilder.error(nat, "Syntax error: a target platform has already been defined as \"{previous_target_platform}\".") + modelbuilder.error(nat, "Syntax Error: a target platform has already been defined as `{previous_target_platform}`.") end mmodule.local_target_platform = platform diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index 73cc176..3f81bf8 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -321,7 +321,7 @@ class RapidTypeAnalysis do var d = mtype.length if d > 255 then - self.modelbuilder.toolcontext.fatal_error(null, "Fatal error: limitation in the rapidtype analysis engine: a type depth of {d} is too important, the problematic type is {mtype}.") + self.modelbuilder.toolcontext.fatal_error(null, "Fatal Error: limitation in the rapidtype analysis engine: a type depth of {d} is too important, the problematic type is `{mtype}`.") end end diff --git a/src/semantize/auto_super_init.nit b/src/semantize/auto_super_init.nit index 07b4f46..cb4b70a 100644 --- a/src/semantize/auto_super_init.nit +++ b/src/semantize/auto_super_init.nit @@ -69,7 +69,7 @@ redef class AMethPropdef # Collect only for constructors if not mpropdef.mproperty.is_init or mpropdef.mproperty.is_new then - if nosuper != null then modelbuilder.error(nosuper, "Error: nosuper only in `init`") + if nosuper != null then modelbuilder.error(nosuper, "Error: `nosuper` only allowed in `init`.") return end @@ -89,7 +89,7 @@ redef class AMethPropdef v.enter_visit(nblock) var anode = v.has_explicit_super_init if anode != null then - if nosuper != null then modelbuilder.error(anode, "Error: method is annotated nosuper but a constructor call is present") + if nosuper != null then modelbuilder.error(anode, "Error: method is annotated `nosuper` but a super-constructor call is present.") return end if v.is_broken then return # skip @@ -119,7 +119,7 @@ redef class AMethPropdef candidate = modelbuilder.try_get_mproperty_by_name2(self, mmodule, msupertype, "init") end if candidate == null then - modelbuilder.error(self, "Error: Cannot do an implicit constructor call in {mpropdef}; there is no constructor named {mpropdef.mproperty.name} in {msupertype}.") + modelbuilder.error(self, "Error: cannot do an implicit constructor call in `{mpropdef}`; there is no constructor named `{mpropdef.mproperty.name}` in `{msupertype}`.") return end assert candidate isa MMethod @@ -158,7 +158,7 @@ redef class AMethPropdef var i = 0 for p in spd.initializers do if p != candidatedef.initializers[i] then - modelbuilder.error(self, "Error: Cannot do an implicit constructor call to comflicting for inherited inits {spd}({spd.initializers.join(", ")}) and {candidatedef}({candidatedef.initializers.join(", ")}). NOTE: Do not mix old-style and new-style init!") + modelbuilder.error(self, "Error: cannot do an implicit constructor call to conflicting inherited inits `{spd}({spd.initializers.join(", ")}`) and `{candidatedef}({candidatedef.initializers.join(", ")}`). NOTE: Do not mix old-style and new-style init!") return end i += 1 @@ -174,7 +174,7 @@ redef class AMethPropdef modelbuilder.toolcontext.info("Auto-super init for {mpropdef} to {the_root_init_mmethod.full_name}", 4) end if auto_super_inits.is_empty then - modelbuilder.error(self, "Error: No constructors to call implicitely in {mpropdef}. Call one explicitely.") + modelbuilder.error(self, "Error: no constructors to call implicitly in `{mpropdef}`. Call one explicitly.") return end @@ -184,7 +184,7 @@ redef class AMethPropdef var msig = mpropdef.msignature.as(not null) var supermsig = auto_super_init.msignature if supermsig.arity > msig.arity then - modelbuilder.error(self, "Error: Cannot do an implicit constructor call to {auto_super_init_def}{supermsig}. Expected at least {supermsig.arity} arguments, got {msig.arity}.") + modelbuilder.error(self, "Error: cannot do an implicit constructor call to `{auto_super_init_def}{supermsig}`. Expected at least `{supermsig.arity}` arguments, got `{msig.arity}`.") continue end var i = 0 @@ -193,7 +193,7 @@ redef class AMethPropdef var sub = p.mtype var sup = sp.mtype if not sub.is_subtype(mmodule, anchor, sup) then - modelbuilder.error(self, "Error: Cannot do an implicit constructor call to {auto_super_init_def}{supermsig}. Expected argument #{i} of type {sp.mtype}, got implicit argument {p.name} of type {p.mtype}.") + modelbuilder.error(self, "Error: cannot do an implicit constructor call to `{auto_super_init_def}{supermsig}`. Expected argument #{i} of type `{sp.mtype}`, got implicit argument `{p.name}` of type `{p.mtype}`.") break end i += 1 diff --git a/src/semantize/local_var_init.nit b/src/semantize/local_var_init.nit index 82fa0a4..27c7ddd 100644 --- a/src/semantize/local_var_init.nit +++ b/src/semantize/local_var_init.nit @@ -70,7 +70,7 @@ private class LocalVarInitVisitor var flow = node.after_flow_context.as(not null) if not flow.is_variable_set(variable) then - self.toolcontext.error(node.hot_location, "Error: variable '{variable}' is possibly unset.") + self.toolcontext.error(node.hot_location, "Error: possibly unset variable `{variable}`.") # Remove the variable to avoid repeating errors self.maybe_unset_vars.remove(variable) end diff --git a/src/semantize/scope.nit b/src/semantize/scope.nit index 749bb9e..4ea5f27 100644 --- a/src/semantize/scope.nit +++ b/src/semantize/scope.nit @@ -99,7 +99,7 @@ private class ScopeVisitor var name = variable.name var found = search_variable(name) if found != null then - self.error(node, "Error: A variable named `{name}' already exists") + self.error(node, "Error: a variable named `{name}` already exists.") return false end scopes.first.variables[name] = variable @@ -160,14 +160,14 @@ private class ScopeVisitor if nid == null then var res = search_label("") if res != null then - self.error(nlabel, "Syntax error: anonymous label already defined.") + self.error(nlabel, "Syntax Error: anonymous label already defined.") end name = "" else name = nid.text var found = self.search_label(name) if found != null then - self.error(nlabel, "Syntax error: label {name} already defined.") + self.error(nlabel, "Syntax Error: label `{name}` already defined.") end end else @@ -190,7 +190,7 @@ private class ScopeVisitor if nid == null then var res = search_label("") if res == null then - self.error(nlabel, "Syntax error: invalid anonymous label.") + self.error(nlabel, "Syntax Error: invalid anonymous label.") return null end return res @@ -198,7 +198,7 @@ private class ScopeVisitor var name = nid.text var res = search_label(name) if res == null then - self.error(nlabel, "Syntax error: invalid label {name}.") + self.error(nlabel, "Syntax Error: invalid label `{name}`.") return null end return res @@ -209,7 +209,7 @@ private class ScopeVisitor return res end end - self.error(node, "Syntax Error: 'break' statement outside block.") + self.error(node, "Syntax Error: `break` statement outside block.") return null end end @@ -443,7 +443,7 @@ redef class ACallFormExpr if variable != null then var n: AExpr if not n_args.n_exprs.is_empty or n_args isa AParExprs then - v.error(self, "Error: {name} is variable, not a function.") + v.error(self, "Error: `{name}` is a variable, not a method.") return end n = variable_create(variable) diff --git a/src/semantize/typing.nit b/src/semantize/typing.nit index 4bef8a2..e7a5a09 100644 --- a/src/semantize/typing.nit +++ b/src/semantize/typing.nit @@ -118,9 +118,9 @@ private class TypeVisitor end if sub.need_anchor then var u = anchor_to(sub) - self.modelbuilder.error(node, "Type error: expected {sup}, got {sub}: {u}") + self.modelbuilder.error(node, "Type Error: expected `{sup}`, got `{sub}: {u}`.") else - self.modelbuilder.error(node, "Type error: expected {sup}, got {sub}") + self.modelbuilder.error(node, "Type Error: expected `{sup}`, got `{sub}`.") end return null end @@ -150,7 +150,7 @@ private class TypeVisitor end return null # forward error end - self.error(nexpr, "Type error: expected expression.") + self.error(nexpr, "Error: expected an expression.") return null end @@ -193,9 +193,9 @@ private class TypeVisitor if sup == null then return null # Forward error if sup == sub then - self.modelbuilder.warning(node, "useless-type-test", "Warning: Expression is already a {sup}.") + self.modelbuilder.warning(node, "useless-type-test", "Warning: expression is already a `{sup}`.") else if self.is_subtype(sub, sup) then - self.modelbuilder.warning(node, "useless-type-test", "Warning: Expression is already a {sup} since it is a {sub}.") + self.modelbuilder.warning(node, "useless-type-test", "Warning: expression is already a `{sup}` since it is a `{sub}`.") end return sup end @@ -307,7 +307,7 @@ private class TypeVisitor if objclass == null then return null # Forward error unsafe_type = objclass.mclass_type else - self.error(node, "Error: Method '{name}' call on 'null'.") + self.error(node, "Error: method `{name}` called on `null`.") return null end end @@ -319,11 +319,12 @@ private class TypeVisitor end if mproperty == null then - #self.modelbuilder.error(node, "Type error: property {name} not found in {unsafe_type} (ie {recvtype})") if recv_is_self then - self.modelbuilder.error(node, "Error: Method or variable '{name}' unknown in {recvtype}.") + self.modelbuilder.error(node, "Error: method or variable `{name}` unknown in `{recvtype}`.") + else if recvtype.need_anchor then + self.modelbuilder.error(node, "Error: method `{name}` does not exists in `{recvtype}: {unsafe_type}`.") else - self.modelbuilder.error(node, "Error: Method '{name}' doesn't exists in {recvtype}.") + self.modelbuilder.error(node, "Error: method `{name}` does not exists in `{recvtype}`.") end return null end @@ -331,14 +332,14 @@ private class TypeVisitor assert mproperty isa MMethod if is_toplevel_context and recv_is_self and not mproperty.is_toplevel then - error(node, "Error: '{name}' is not a top-level method, thus need a receiver.") + error(node, "Error: `{name}` is not a top-level method, thus need a receiver.") end if not recv_is_self and mproperty.is_toplevel then - error(node, "Error: cannot call '{name}', a top-level method, with a receiver.") + error(node, "Error: cannot call `{name}`, a top-level method, with a receiver.") end if mproperty.visibility == protected_visibility and not recv_is_self and self.mmodule.visibility_for(mproperty.intro_mclassdef.mmodule) < intrude_visibility and not modelbuilder.toolcontext.opt_ignore_visibility.value then - self.modelbuilder.error(node, "Error: Method '{name}' is protected and can only acceded by self.") + self.modelbuilder.error(node, "Error: method `{name}` is protected and can only accessed by `self`.") return null end @@ -346,21 +347,21 @@ private class TypeVisitor if info != null and self.mpropdef.mproperty.deprecation == null then var mdoc = info.mdoc if mdoc != null then - self.modelbuilder.warning(node, "deprecated-method", "Deprecation Warning: Method '{name}' is deprecated: {mdoc.content.first}") + self.modelbuilder.warning(node, "deprecated-method", "Deprecation Warning: method `{name}` is deprecated: {mdoc.content.first}") else - self.modelbuilder.warning(node, "deprecated-method", "Deprecation Warning: Method '{name}' is deprecated.") + self.modelbuilder.warning(node, "deprecated-method", "Deprecation Warning: method `{name}` is deprecated.") end end var propdefs = mproperty.lookup_definitions(self.mmodule, unsafe_type) var mpropdef if propdefs.length == 0 then - self.modelbuilder.error(node, "Type error: no definition found for property {name} in {unsafe_type}") + self.modelbuilder.error(node, "Type Error: no definition found for property `{name}` in `{unsafe_type}`.") return null else if propdefs.length == 1 then mpropdef = propdefs.first else - self.modelbuilder.warning(node, "property-conflict", "Warning: conflicting property definitions for property {name} in {unsafe_type}: {propdefs.join(" ")}") + self.modelbuilder.warning(node, "property-conflict", "Warning: conflicting property definitions for property `{name}` in `{unsafe_type}`: {propdefs.join(" ")}") mpropdef = mproperty.intro end @@ -397,17 +398,16 @@ private class TypeVisitor # Visit the expressions of args and check their conformity with the corresponding type in signature # The point of this method is to handle varargs correctly # Note: The signature must be correctly adapted - fun check_signature(node: ANode, args: Array[AExpr], name: String, msignature: MSignature): Bool + fun check_signature(node: ANode, args: Array[AExpr], mproperty: MProperty, msignature: MSignature): Bool do var vararg_rank = msignature.vararg_rank if vararg_rank >= 0 then if args.length < msignature.arity then - #self.modelbuilder.error(node, "Error: Incorrect number of parameters. Got {args.length}, expected at least {msignature.arity}. Signature is {msignature}") - self.modelbuilder.error(node, "Error: arity mismatch; prototype is '{name}{msignature}'") + modelbuilder.error(node, "Error: expected at least {msignature.arity} argument(s) for `{mproperty}{msignature}`; got {args.length}. See introduction at `{mproperty.full_name}`.") return false end else if args.length != msignature.arity then - self.modelbuilder.error(node, "Error: Incorrect number of parameters. Got {args.length}, expected {msignature.arity}. Signature is {msignature}") + modelbuilder.error(node, "Error: expected {msignature.arity} argument(s) for `{mproperty}{msignature}`; got {args.length}. See introduction at `{mproperty.full_name}`.") return false end @@ -451,10 +451,7 @@ private class TypeVisitor if not variable.is_adapted then return variable.declared_type var flow = node.after_flow_context - if flow == null then - self.error(node, "No context!") - return null - end + if flow == null then return null # skip error if flow.vars.has_key(variable) then return flow.vars[variable] @@ -545,7 +542,7 @@ class CallSite private fun check_signature(v: TypeVisitor, args: Array[AExpr]): Bool do - return v.check_signature(self.node, args, self.mproperty.name, self.msignature) + return v.check_signature(self.node, args, self.mproperty, self.msignature) end end @@ -653,7 +650,7 @@ redef class AMethPropdef if not nblock.after_flow_context.is_unreachable and msignature.return_mtype != null then # We reach the end of the function without having a return, it is bad - v.error(self, "Control error: Reached end of function (a 'return' with a value was expected).") + v.error(self, "Error: reached end of function; expected `return` with a value.") end end end @@ -679,7 +676,7 @@ redef class AAttrPropdef v.visit_stmt(nblock) if not nblock.after_flow_context.is_unreachable then # We reach the end of the init without having a return, it is bad - v.error(self, "Control error: Reached end of block (a 'return' with a value was expected).") + v.error(self, "Error: reached end of block; expected `return`.") end end end @@ -836,7 +833,7 @@ redef class AReassignFormExpr self.read_type = readtype - var callsite = v.get_method(self, readtype, reassign_name, false) + var callsite = v.get_method(self.n_assign_op, readtype, reassign_name, false) if callsite == null then return null # Skip error self.reassign_callsite = callsite @@ -915,10 +912,10 @@ redef class AReturnExpr v.visit_expr_subtype(nexpr, ret_type) else v.visit_expr(nexpr) - v.error(self, "Error: Return with value in a procedure.") + v.error(nexpr, "Error: `return` with value in a procedure.") end else if ret_type != null then - v.error(self, "Error: Return without value in a function.") + v.error(self, "Error: `return` without value in a function.") end self.is_typed = true end @@ -961,7 +958,7 @@ redef class AIfexprExpr var t = v.merge_types(self, [t1, t2]) if t == null then - v.error(self, "Type Error: ambiguous type {t1} vs {t2}") + v.error(self, "Type Error: ambiguous type `{t1}` vs `{t2}`.") end self.mtype = t end @@ -1010,7 +1007,7 @@ redef class AForExpr private fun do_type_iterator(v: TypeVisitor, mtype: MType) do if mtype isa MNullType then - v.error(self, "Type error: 'for' cannot iterate over 'null'") + v.error(self, "Type Error: `for` cannot iterate over `null`.") return end @@ -1021,7 +1018,7 @@ redef class AForExpr # check iterator method var itdef = v.get_method(self, mtype, "iterator", n_expr isa ASelfExpr) if itdef == null then - v.error(self, "Type Error: 'for' expects a type providing 'iterator' method, got '{mtype}'.") + v.error(self, "Type Error: `for` expects a type providing an `iterator` method, got `{mtype}`.") return end self.method_iterator = itdef @@ -1029,7 +1026,7 @@ redef class AForExpr # check that iterator return something var ittype = itdef.msignature.return_mtype if ittype == null then - v.error(self, "Type Error: 'for' expects method 'iterator' to return an 'Iterator' or 'MapIterator' type'.") + v.error(self, "Type Error: `for` expects the method `iterator` to return an `Iterator` or `MapIterator` type.") return end @@ -1044,7 +1041,7 @@ redef class AForExpr var coltype = ittype.supertype_to(v.mmodule, v.anchor, colit_cla) var variables = self.variables if variables.length != 1 then - v.error(self, "Type Error: 'for' expects only one variable when using 'Iterator'.") + v.error(self, "Type Error: `for` expects only one variable when using `Iterator`.") else variables.first.declared_type = coltype.arguments.first end @@ -1056,7 +1053,7 @@ redef class AForExpr var coltype = ittype.supertype_to(v.mmodule, v.anchor, mapit_cla) var variables = self.variables if variables.length != 2 then - v.error(self, "Type Error: 'for' expects two variables when using 'MapIterator'.") + v.error(self, "Type Error: `for` expects two variables when using `MapIterator`.") else variables[0].declared_type = coltype.arguments[0] variables[1].declared_type = coltype.arguments[1] @@ -1065,7 +1062,7 @@ redef class AForExpr end if not is_col and not is_map then - v.error(self, "Type Error: 'for' expects method 'iterator' to return an 'Iterator' or 'MapIterator' type'.") + v.error(self, "Type Error: `for` expects the method `iterator` to return an `Iterator` or `MapIterator` type.") return end @@ -1078,21 +1075,21 @@ redef class AForExpr # get methods is_ok, next, item var ikdef = v.get_method(self, ittype, "is_ok", false) if ikdef == null then - v.error(self, "Type Error: 'for' expects a method 'is_ok' in 'Iterator' type {ittype}.") + v.error(self, "Type Error: `for` expects a method `is_ok` in type `{ittype}`.") return end self.method_is_ok = ikdef var itemdef = v.get_method(self, ittype, "item", false) if itemdef == null then - v.error(self, "Type Error: 'for' expects a method 'item' in 'Iterator' type {ittype}.") + v.error(self, "Type Error: `for` expects a method `item` in type `{ittype}`.") return end self.method_item = itemdef var nextdef = v.get_method(self, ittype, "next", false) if nextdef == null then - v.error(self, "Type Error: 'for' expects a method 'next' in 'Iterator' type {ittype}.") + v.error(self, "Type Error: `for` expects a method `next` in type {ittype}.") return end self.method_next = nextdef @@ -1102,7 +1099,7 @@ redef class AForExpr if is_map then var keydef = v.get_method(self, ittype, "key", false) if keydef == null then - v.error(self, "Type Error: 'for' expects a method 'key' in 'Iterator' type {ittype}.") + v.error(self, "Type Error: `for` expects a method `key` in type `{ittype}`.") return end self.method_key = keydef @@ -1212,7 +1209,7 @@ redef class AOrElseExpr end if t1 isa MNullType then - v.error(n_expr, "Type error: or else on null") + v.error(n_expr, "Type Error: `or else` on `null`.") else if v.check_can_be_null(n_expr, t1) then t1 = t1.as_notnull end @@ -1391,7 +1388,7 @@ redef class ARangeExpr else if v.is_subtype(t2, t1) then mtype = mclass.get_mtype([t1]) else - v.error(self, "Type Error: Cannot create range: {t1} vs {t2}") + v.error(self, "Type Error: cannot create range: `{t1}` vs `{t2}`.") return end @@ -1453,7 +1450,7 @@ redef class AAsNotnullExpr if mtype == null then return # Forward error if mtype isa MNullType then - v.error(self, "Type error: as(not null) on null") + v.error(self, "Type Error: `as(not null)` on `null`.") return end @@ -1484,7 +1481,7 @@ redef class ASelfExpr redef fun accept_typing(v) do if v.is_toplevel_context and not self isa AImplicitSelfExpr then - v.error(self, "Error: self cannot be used in top-level method.") + v.error(self, "Error: `self` cannot be used in top-level method.") end var variable = v.selfvariable self.its_variable = variable @@ -1512,20 +1509,21 @@ redef class ASendExpr var nrecv = self.n_expr var recvtype = v.visit_expr(nrecv) var name = self.property_name + var node = self.property_node if recvtype == null then return # Forward error var callsite = null var unsafe_type = v.anchor_to(recvtype) - var mproperty = v.try_get_mproperty_by_name2(self, unsafe_type, name) + var mproperty = v.try_get_mproperty_by_name2(node, unsafe_type, name) if mproperty == null and nrecv isa AImplicitSelfExpr then # Special fall-back search in `sys` when noting found in the implicit receiver. - var sysclass = v.try_get_mclass(self, "Sys") + var sysclass = v.try_get_mclass(node, "Sys") if sysclass != null then var systype = sysclass.mclass_type - mproperty = v.try_get_mproperty_by_name2(self, systype, name) + mproperty = v.try_get_mproperty_by_name2(node, systype, name) if mproperty != null then - callsite = v.get_method(self, systype, name, false) + callsite = v.get_method(node, systype, name, false) if callsite == null then return # Forward error # Update information, we are looking at `sys` now, not `self` nrecv.is_sys = true @@ -1537,7 +1535,7 @@ redef class ASendExpr end if callsite == null then # If still nothing, just exit - callsite = v.get_method(self, recvtype, name, nrecv isa ASelfExpr) + callsite = v.get_method(node, recvtype, name, nrecv isa ASelfExpr) if callsite == null then return end @@ -1551,10 +1549,10 @@ redef class ASendExpr if callsite.mproperty.is_init then var vmpropdef = v.mpropdef if not (vmpropdef isa MMethodDef and vmpropdef.mproperty.is_init) then - v.error(self, "Can call a init only in another init") + v.error(node, "Error: an `init` can only be called from another `init`.") end if vmpropdef isa MMethodDef and vmpropdef.mproperty.is_root_init and not callsite.mproperty.is_root_init then - v.error(self, "Error: {vmpropdef} cannot call a factory {callsite.mproperty}") + v.error(node, "Error: `{vmpropdef}` cannot call a factory `{callsite.mproperty}`.") end end @@ -1702,7 +1700,7 @@ redef class ASendReassignFormExpr var readtype = callsite.msignature.return_mtype if readtype == null then - v.error(self, "Error: {name} is not a function") + v.error(node, "Error: `{name}` is not a function.") return end @@ -1761,7 +1759,7 @@ redef class ASuperExpr assert recvtype != null var mproperty = v.mpropdef.mproperty if not mproperty isa MMethod then - v.error(self, "Error: super only usable in a method") + v.error(self, "Error: `super` only usable in a `method`.") return end var superprops = mproperty.lookup_super_definitions(v.mmodule, anchor) @@ -1770,7 +1768,7 @@ redef class ASuperExpr process_superinit(v) return end - v.error(self, "Error: No super method to call for {mproperty}.") + v.error(self, "Error: no super method to call for `{mproperty}`.") return end # FIXME: covariance of return type in linear extension? @@ -1780,7 +1778,7 @@ redef class ASuperExpr msignature = v.resolve_for(msignature, recvtype, true).as(MSignature) var args = self.n_args.to_a if args.length > 0 then - v.check_signature(self, args, mproperty.name, msignature) + v.check_signature(self, args, mproperty, msignature) end self.mtype = msignature.return_mtype self.is_typed = true @@ -1810,7 +1808,7 @@ redef class ASuperExpr continue end if superprop != null and superprop.mproperty != candidate and not superprop.mproperty.is_root_init then - v.error(self, "Error: conflicting super constructor to call for {mproperty}: {candidate.full_name}, {superprop.mproperty.full_name}") + v.error(self, "Error: conflicting super constructor to call for `{mproperty}`: `{candidate.full_name}`, `{superprop.mproperty.full_name}`") return end var candidatedefs = candidate.lookup_definitions(v.mmodule, anchor) @@ -1819,13 +1817,13 @@ redef class ASuperExpr candidatedefs.add(superprop) end if candidatedefs.length > 1 then - v.error(self, "Error: conflicting property definitions for property {mproperty} in {recvtype}: {candidatedefs.join(", ")}") + v.error(self, "Error: conflicting property definitions for property `{mproperty}` in `{recvtype}`: {candidatedefs.join(", ")}") return end superprop = candidatedefs.first end if superprop == null then - v.error(self, "Error: No super method to call for {mproperty}.") + v.error(self, "Error: no super method to call for `{mproperty}`.") return end @@ -1841,7 +1839,7 @@ redef class ASuperExpr else # Check there is at least enough parameters if mpropdef.msignature.arity < msignature.arity then - v.error(self, "Error: Not enough implicit arguments to pass. Got {mpropdef.msignature.arity}, expected at least {msignature.arity}. Signature is {msignature}") + v.error(self, "Error: not enough implicit arguments to pass. Got `{mpropdef.msignature.arity}`, expected at least `{msignature.arity}`. Signature is `{msignature}`.") return end # Check that each needed parameter is conform @@ -1849,7 +1847,7 @@ redef class ASuperExpr for sp in msignature.mparameters do var p = mpropdef.msignature.mparameters[i] if not v.is_subtype(p.mtype, sp.mtype) then - v.error(self, "Type error: expected argument #{i} of type {sp.mtype}, got implicit argument {p.name} of type {p.mtype}. Signature is {msignature}") + v.error(self, "Type Error: expected argument #{i} of type `{sp.mtype}`, got implicit argument `{p.name}` of type `{p.mtype}`. Signature is {msignature}") return end i += 1 @@ -1876,10 +1874,13 @@ redef class ANewExpr if not recvtype isa MClassType then if recvtype isa MNullableType then - v.error(self, "Type error: cannot instantiate the nullable type {recvtype}.") + v.error(self, "Type Error: cannot instantiate the nullable type `{recvtype}`.") + return + else if recvtype isa MFormalType then + v.error(self, "Type Error: cannot instantiate the formal type `{recvtype}`.") return else - v.error(self, "Type error: cannot instantiate the formal type {recvtype}.") + v.error(self, "Type Error: cannot instantiate the type `{recvtype}`.") return end end @@ -1899,7 +1900,7 @@ redef class ANewExpr end if name == "intern" then if kind != concrete_kind then - v.error(self, "Type Error: Cannot instantiate {kind} {recvtype}.") + v.error(self, "Type Error: cannot instantiate {kind} {recvtype}.") return end if n_args.n_exprs.not_empty then @@ -1916,7 +1917,7 @@ redef class ANewExpr if not callsite.mproperty.is_new then if kind != concrete_kind then - v.error(self, "Type Error: Cannot instantiate {kind} {recvtype}.") + v.error(self, "Type Error: cannot instantiate {kind} `{recvtype}`.") return end self.mtype = recvtype @@ -1928,7 +1929,7 @@ redef class ANewExpr self.callsite = callsite if not callsite.mproperty.is_init_for(recvtype.mclass) then - v.error(self, "Error: {name} is not a constructor.") + v.error(self, "Error: `{name}` is not a constructor.") return end @@ -1940,27 +1941,28 @@ end #### redef class AAttrFormExpr - # The attribute acceded. + # The attribute accessed. var mproperty: nullable MAttribute # The static type of the attribute. var attr_type: nullable MType - # Resolve the attribute acceded. + # Resolve the attribute accessed. private fun resolve_property(v: TypeVisitor) do var recvtype = v.visit_expr(self.n_expr) if recvtype == null then return # Skip error - var name = self.n_id.text + var node = self.n_id + var name = node.text if recvtype isa MNullType then - v.error(self, "Error: Attribute '{name}' access on 'null'.") + v.error(node, "Error: attribute `{name}` access on `null`.") return end var unsafe_type = v.anchor_to(recvtype) - var mproperty = v.try_get_mproperty_by_name2(self, unsafe_type, name) + var mproperty = v.try_get_mproperty_by_name2(node, unsafe_type, name) if mproperty == null then - v.modelbuilder.error(self, "Error: Attribute {name} doesn't exists in {recvtype}.") + v.modelbuilder.error(node, "Error: attribute `{name}` does not exist in `{recvtype}`.") return end assert mproperty isa MAttribute @@ -2019,7 +2021,7 @@ redef class AIssetAttrExpr var recvtype = self.n_expr.mtype.as(not null) var bound = v.resolve_for(mtype, recvtype, false) if bound isa MNullableType then - v.error(self, "Error: isset on a nullable attribute.") + v.error(n_id, "Type Error: `isset` on a nullable attribute.") end self.mtype = v.type_bool(self) end @@ -2031,7 +2033,7 @@ redef class AVarargExpr # This kind of pseudo-expression can be only processed trough a signature # See `check_signature` # Other cases are a syntax error. - v.error(self, "Syntax error: unexpected `...`") + v.error(self, "Syntax Error: unexpected `...`.") end end diff --git a/src/test_parser.nit b/src/test_parser.nit index 8acb62c..6ad8038 100644 --- a/src/test_parser.nit +++ b/src/test_parser.nit @@ -82,10 +82,10 @@ if (args.is_empty and not interactive) or need_help then print(" -h print this help") else if interactive then if only_lexer then - print "Error: -l and -i are incompatibles" + print "Error: -l and -i are incompatible" exit 1 else if no_file then - print "Error: -e and -i are incompatibles" + print "Error: -e and -i are incompatible" exit 1 else if not args.is_empty then print "Error: -i works without arguments" diff --git a/src/testing/testing_doc.nit b/src/testing/testing_doc.nit index 563c418..7d4afe6 100644 --- a/src/testing/testing_doc.nit +++ b/src/testing/testing_doc.nit @@ -57,7 +57,7 @@ class NitUnitExecutor if not (ast isa AModule or ast isa ABlockExpr or ast isa AExpr) then var message = "" if ast isa AError then message = " At {ast.location}: {ast.message}." - toolcontext.warning(mdoc.location, "invalid-block", "Error: There is a block of code that is not valid Nit, thus not considered a nitunit. To suppress this warning, enclose the block with a fence tagged `nitish` or `raw` (see `man nitdoc`).{message}") + toolcontext.warning(mdoc.location, "invalid-block", "Error: there is a block of invalid Nit code, thus not considered a nitunit. To suppress this warning, enclose the block with a fence tagged `nitish` or `raw` (see `man nitdoc`).{message}") failures.add("{mdoc.location}: Invalid block of code.{message}") return end @@ -291,16 +291,16 @@ class NitUnitExecutor private fun compile_unitfile(file: String): Int do var nit_dir = toolcontext.nit_dir - var nitg = nit_dir/"bin/nitg" - if not nitg.file_exists then - toolcontext.error(null, "Cannot find nitg. Set envvar NIT_DIR.") + var nitc = nit_dir/"bin/nitc" + if not nitc.file_exists then + toolcontext.error(null, "Error: cannot find nitc. Set envvar NIT_DIR.") toolcontext.check_errors end var opts = new Array[String] if mmodule != null then opts.add "-I {mmodule.location.file.filename.dirname}" end - var cmd = "{nitg} --ignore-visibility --no-color '{file}' {opts.join(" ")} >'{file}.out1' 2>&1 '{file}.out1' 2>&1