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
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
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
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
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
# 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
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
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
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
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
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
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
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
# 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
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
# 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))
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
# 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
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
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
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
# 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
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
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]
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
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
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
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
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
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
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
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
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
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)
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
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
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
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
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
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
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
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
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)
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
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
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
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
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
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}"
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
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
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
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
# 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
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
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
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
# 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
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
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
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
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
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
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
# 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)
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
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
# 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
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)
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
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
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
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
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
end
if mtype == null then
- modelbuilder.error(self, "Error: Untyped attribute {mreadpropdef}")
+ modelbuilder.error(self, "Error: untyped attribute `{mreadpropdef}`.")
return
end
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
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
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
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
# 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
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
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
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
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
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
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
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
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
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
#
# 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
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
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
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
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)
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
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
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
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]
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
# 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
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
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
# 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
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
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
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
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
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
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
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
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
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
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
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
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
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)
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
end
return null # forward error
end
- self.error(nexpr, "Type error: expected expression.")
+ self.error(nexpr, "Error: expected an expression.")
return null
end
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
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
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
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
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
# 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
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]
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
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
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
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
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
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
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
# 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
# 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
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
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]
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
# 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
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
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
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
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
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
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
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
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
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
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)
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?
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
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)
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
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
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
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
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
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
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
####
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
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
# 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
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"
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
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 </dev/null -o '{file}.bin'"
+ var cmd = "{nitc} --ignore-visibility --no-color '{file}' {opts.join(" ")} >'{file}.out1' 2>&1 </dev/null -o '{file}.bin'"
var res = sys.system(cmd)
return res
end
# Compile all `test_cases` cases in one file.
fun compile do
- # find nitg
+ # find nitc
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
# compile test suite
var file = test_file
var include_dir = mmodule.location.file.filename.dirname
- var cmd = "{nitg} --no-color '{file}.nit' -I {include_dir} -o '{file}.bin' > '{file}.out' 2>&1 </dev/null"
+ var cmd = "{nitc} --no-color '{file}.nit' -I {include_dir} -o '{file}.bin' > '{file}.out' 2>&1 </dev/null"
var res = sys.system(cmd)
var f = new FileReader.open("{file}.out")
var msg = f.read_all
# Test method to be compiled and tested.
var test_method: MMethodDef
- # `ToolContext` to use to display messages and find `nitg` bin.
+ # `ToolContext` to use to display messages and find `nitc` bin.
var toolcontext: ToolContext
# `MMethodDef` to call before the test case.
# The human-readable description of the message.
#
- # It should be short and fit on a single line.
- # It should also have meaningful information first in case
- # on truncation by an IDE for instance.
+ # eg. "Error: cannot find method `foo`."
+ #
+ # A good message should:
+ #
+ # * start with a message type like "Error:", "Syntax Error:", "Warning:".
+ # The type is capitalized and terminated by a column.
+ # The rest on the message starts with a lowercase letter and is terminated with a dot.
+ #
+ # * be short and fit on a single line.
+ #
+ # * have meaningful information first.
+ # This helps the reader and remain usable
+ # when truncated, by an IDE for instance.
+ #
+ # * enclose identifiers, keywords and pieces of code with back-quotes.
var text: String
# Comparisons are made on message locations.
var res = opt_nit_dir.value
if res != null then
if not check_nit_dir(res) then
- fatal_error(null, "Fatal Error: the value of --nit-dir does not seem to be a valid base Nit directory: {res}")
+ fatal_error(null, "Fatal Error: the value of --nit-dir does not seem to be a valid base Nit directory: {res}.")
end
return res
end
res = "NIT_DIR".environ
if not res.is_empty then
if not check_nit_dir(res) then
- fatal_error(null, "Fatal Error: the value of NIT_DIR does not seem to be a valid base Nit directory: {res}")
+ fatal_error(null, "Fatal Error: the value of NIT_DIR does not seem to be a valid base Nit directory: {res}.")
end
return res
end
if check_nit_dir(res) then return res.simplify_path
end
- fatal_error(null, "Fatal Error: Cannot locate a valid base nit directory. It is quite unexpected. Try to set the environment variable `NIT_DIR` or to use the `--nit-dir` option.")
+ fatal_error(null, "Fatal Error: cannot locate a valid base Nit directory. It is quite unexpected. Try to set the environment variable `NIT_DIR` or to use the `--nit-dir` option.")
abort
end