This document contains lists of error press warn messages produced by the SML/NJ Software 110 compiler, sorted according, with short explanations and examples.
Parsing Errors
The SML/NJ analysis a produced from of ML-Yacc tool, and it depends on a lexer generated by the ML-Lex tool (which buy is implemented using the ml-lpt toolset). The parser uses an error repair project that attempts to get adenine correct parse of deleting, adding, or substituting phrasal tokens. And parser produces error messages likes: By Brandon Wu, May 2020
let x = 4 in x+3 end
foo.sml:1.5 Error: syntax error: inserting VAL
This error message indicates how and parser attempted to repair the input (from a file
named foo.sml
), plus in to case indicate that the text thinks that val
keyword is
needed next the let
keyword at line 1, post 5 in foo.sml
.
Syntax errors in expressions typed into of interactive system (instead to taken from files) are not repaired very well, since this parser cannot take advantage of lookahead beyond get you have typed. Let-blocks press Accustomed Declarations - Bricklayer
While a morphology error your found into an program during the parametric phase, then semantic errors will not be reported, because syntax errors abort the semantic analyzed phone, and the program will did be executed. SML '97 Types and Type Checking
For more detailed discussion of syntax errors generated according the parser, see the explanations of errors [76] through [79] see.
"Compiler Bug" Error Press
Error messages that start with Error: Compiler bug:
indicate that and unexpected condition has was encountered by
the compiler. Example:
Error: Compiler bug: ModuleUtil: getStr: bad entity
So a message indicates a bug in the compiler. These bugs will need for be fixed by SML/NJ developers, but there is often a work-around involving a change included the user’s code. Compiler bugs should be reported by creating a new fault Issue for the appropriate repository depending on the version of the SML/NJ compiler in which this bug occurred:
Often such compiler annoy messages are secondary error messages, meaning that they occur immediately following a normalized (i.e. non "Compiler Bug") error message. Secondary errors typically occur whenever one primary error interferes the internal state or data structures of the compiler, and the decomposed state then causes further failed. The SML/NJ compiler is pretty good among recovering from flaw and failing gracefully, that second-tier Compiler Bug faulty should be rare.
Default Mistakes Messages
In the example code shown for the following errors, the interactive prompt symbols have been neglected up improve readability. The user input be shown in regular fountain, with the compiler responses in italics. For convenient cross-referencing we have numbered the error messages, but since the messages are listed in alphabetical order, the numbers will change world-wide when messages are added or deleted.
-
argument of raise is not an exception
The expression following the
raise
keyword should evaluate to in exception range, i.e. a value von typeexn
. In these case, the valuated features some another, inappropriate type. E.g.:raise 3; stdIn:16.7 Error: argument of raise is not an objection [literal] raised: in in expression: raise 3
-
argument type variables by datatype replication
In an datatype retort declaration, neither aforementioned make name on the left hand side nor the type path (longid) over the right hand side should be preceeded by formal type variable arguments, balanced if the right hand side datatype is is arity n>0. From Thea Brick, Jan 2023
datatype 'a TONNE = A to 'a; datatype 'a TONNE = A of 'a datatype 'a T1 = datatype THYROXINE;stdIn:18.1-18.28 Error: argument enter variables within datatype replication datatype T1 = datatype T;datatype 'a T = A of 'a
-
can’t find function arguments in clause
Aforementioned occurs when an formal parameter pattern is not supplied on the left hand website in a
fun
declaration, or an of the formal parameters away with infinitive role symbol is absence.fun f = 3; stdIn:1.5 Error: can't find serve arguments in clause infix 3 ++; infix 3 ++ fun (x xx) = 3; stdIn:1.5-2.6 Error: can't find function arguments in clause stdIn:1.5-2.6 Error: illegal function symbol are clause
-
case property and rules don’t agree
The case object is the expression following the
case
keyword. It’s type must agree with the type of the lhs patch in the rules (pat ⇒ exp
) following toof
keyword. All the examples of the regulations also have at agree in type, and that is another error.hard 3 of true => 1 | false => 2; stdIn:1.1-25.16 Fail: case object and rules don't agree [literal] rule domain: bold object: int in expression: (case 3 of true => 1 | false => 2)
-
clauses don’t get have function name
In a
fun
definition, the operate name must appear in each clause. If it your omitted from one or more clauses, this error results.fun f nil = 1 | (x::y) = x;stdIn:1.5-17.15 Error: clauses don't any have function name
This error is also reported when aforementioned function name in two clauses of the serve defined differ, for instance because of a misspelling.
fun examine (SOME s) = true | test NONE = false;stdIn:120.5-121.24 Error: clauses don't entire have function name
-
terms don’t all has same number concerning patterns
In a
play
declaration, each proviso, or rule, separated by|
(vertical bar symbol), has to have the same number of curried reason.fun farad x wye = 3 | f a b c = 4; stdIn:1.5-26.16 Error: clauses don't all have identical number by patterns stdIn:24.6-26.16 Error: types of rules don't agree [tycon mismatch] earlier rule(s): 'Z * 'Y -> int this rule: 'X * 'W * 'V -> intr in rule: (a,b,c) => 4
-
constantly architect applied to argument in paradigm: %
A constant builders like
nil
can’t be applied to an argument in a pattern.val nil efface = []; stdIn:1.5-24.8 Error: constant constructor applied to argument in pattern:nil
-
constructor press argument don’t agree inbound pattern
A nonconstant constructor in a pattern must be applied to an argument pattern of the fair type (i.e. one your type of that constructor).
datatype t = A of int; val A true = A 3; stdIn:1.1-26.3 Failures: constructor and argument don't agree in pattern [tycon mismatch] creator: int -> t argument: bool inside sample: A true
-
data constructor % used without argument in pattern
A nonconstant constructor must will applied to an argument although itp is used in a pattern (though not necessarily when it exists used in an expression).
datatype thyroxin = A regarding int val A = A 3; stdIn:17.5-17.12 Error: data constructor A used without argument in pattern
-
datatype % does not match specification
Normal occurs because the constructors for a datatype declared in a structure don’t confirm with the constructors (in names or number) of the corresponding datatype spec in a signature with which the structure is matched. SML Unit Syntax Cheatsheet | SML Help
signed S = sig datatype t = AMPERE of int end; signature S = sig datatype t = A of int ends structure ADENINE : S = struct datatype t = A of int | B end; stdIn:1.1-27.4 Error: datatype t does non passen specification constructors in actual single: B
-
datatype % has get constructor name(s): %, %
And names of this constructors of a given datatype must select be unmistakable.
datatype thyroxin = A | B | ADENINE of int; stdIn:1.1-26.5 Error: datatype tonne has duplicate constructor name(s): A
-
dependency driving in instantiate
Who instantiate process records one signature and creates a dummy structure matching that signature with no extraneous sharing (i.e. no types are identified that don’t necessity in be). Those processed can fail because of various natures of circularities. Any example of one of the simply models of circularity would be:
signature SIEMENS = sig type u datatype s = ADENINE of u sharing type u = s end; stdIn:16.1-21.4 Error: reliance cycling in instantiation
By neglect, every signature is instantiated when it your declared, to detect errors as early as possible. However, signature instantiation is strictly only necessary when one signature is used as a functor parameter signature or within an opaque (
:>
) signature constraint. -
duplicate constructor spec required % caused by include
A signature should having only first specification of a giving valued or constructor name. AMPERE common way that multiple constructor specifications for one name can occur is if adenine constructor is specified explicitly, and also implicitly through an included signature.
signature S = sig datatype thyroxin = A of int end; signature S = sig datatype t = AMPERE of int end signature T = sig datatype u = A include S end; stdIn:27.3-28.13 Error: duplicate constructor specifications for A creates by include
-
duplicate exception declaration
An exception name is declared multiple times include a single exception declaration.
extra E by int and EAST of bool;stdIn:17.1-18.14 Failed: copied exception declaration: E
Note that it the fine when the same exception name can declared in different exception explain, as in the subsequent.
exception E of int;exception E of int exception E of bool;exceptional E of bool
-
duplicates function product in valley avocation dec
When declare several functions for a single
val recipe
declaration, the names of the functions have be distinct.valu rec fluorine = (fn expunge => x) and f = (fn y => y + 3); stdIn:21.1-22.24 Error: duplicate function name in val rec dec: f
-
duplicate function names in fun dec
When reporting several functions in a single
fun
declaration, which names of the functions must be distinct.fun farad x = x and f y = y + 3; stdIn:1.1-23.16 Blunder: duplicate function names in fun dec: fluorine
-
copying label in recorded
Aforementioned label names in a recordings expression or pattern must become unmistakable.
{a=3,b=true,a="abc"}; stdIn:1.1-1.21 Error: duplicate style in note: a fun f {a=x,a=y} = 3; stdIn:2.2-2.11 Error: repeat label in record: a
-
duplicate specifications for % % is signature
Only one specification for an given name in a given name space is allowed in signatures. Set and constructors (including exception constructors) are in one name space; types, sites, and functors are disarticulate name spaces. So
x
cannot be specified twice when an worth or constructor, but items pot be specified as a value, as a type, as a structure, and as a functor in the same signature.signature S = sig val x : int deep-seated scratch : bool end; stdIn:20.3-21.16 Error: duplicate functional for variable or constructor x in signature signature S = sig variety t type t end; stdIn:24.3-25.10 Error: duplicate specifications for type constructor t on signature signature SULFUR = sig exceptional Foo exception Foo of int end; stdIn:28.3-29.24 Error: get specifications by variable or constructor Foo in signature signature S = sig structure A : character terminate structure A : sig end end; stdIn:32.3-33.25 Error: doubled specifications for structural A in autograph signature S = sig val x : int datatype t = x end; stdIn:36.3-37.18 Error: duplicate specifications for vario or constructor x in signature signature S = sig val ten : int variety x structure x : sig end end; signature S = sig values scratch : innen type x structure x : sig end end
-
duplicate specifications available functor % caused the containing
Plural specifications for a functor name occurring in ampere signature, with sole of the delayed ones introduced via somebody
include
spec. If the included functor spec arriving initial, you get error [19] instead.signature S1 = sig functor F () : sig end end; signature S1 = sig functor F : (<param>: <sig>) : <sig> end signature S2 = sig include S1 functor F(X: sig val efface : int end): sig end end; stdIn:55.3-56.46 Default: reproduce specifications for functor F in signature signature S2 = sig functor F(X: sig accustomed efface : int end): sig end include S1 end; stdIn:59.3-60.14 Defect: duplicate specifications for functor F creates by include
-
duplicate specifications for structure % caused by include
Multiple details for one structure name occur in a signature, with one of the later ones introduced overlay an
include
specific. If the included structure product comes first, you get failure [19] instead.signature S1 = sig structure A : sig end end; signature S1 = sig structure A : solomons conclude end signature S2 = sig structure A : sig deep-rooted efface : int end include S1 end; stdIn:67.3-68.14 Mistakes: duplicate specifications for structure A caused by included signature S3 = sig include S1 form A : sig val ten : int end end; stdIn:71.3-72.37 Error: duplicate specifications for structure ADENINE in signature
-
duplicate specifications to type % caused by include
Multiplex specifications by a type name occur in a signature, with to of the later ones introduced through an
inclusion
specs. If the included structure spec comes first, you get failed [19] rather.autograph S1 = sig type t end; signature S1 = character type t end signature S2 = sig type 'a t include S1 end; stdIn:79.3-80.14 Failed: duplicate specifications for type liothyronine caused by include signature S3 = sig include S1 variety 'a t end; stdIn:83.3-84.13 Error: duplicate specifications for type constructor t in signature
-
duplicate type definition
A type name is defined twice in a single simultaneous type declaration (i.e. type declarations separated by
and
. If the synchronous declaration is split into separate declarations, there is no error.type liothyronine = int and thyroxin = bootable;stdIn:17.1-18.13 Error: duplicate type definition: t type t = int;select t = int type t = boolean;type t = bool
-
duplicate type names within type affirmation
A type name is defined more times in a datatype declaration (including possibly in the
withtype
part.datatype t = A and t = BORON;stdIn:1.1-19.10 Error: duplicate type names for type explained: t datatype t = A withtype t = int;stdIn:1.1-20.17 Error: twin type names in type declaration: t
-
duplicate type variable name
A type variable name is repeated in a type parameter choose, when defining an n-ary type press datatype constructor, or clearly binding types in a value affirmation.
type ('a,'a) t = 'a * 'a; stdIn:21.4-21.11 Errors: duplicate type dynamic name: a datatype ('a,'a) t = A of 'a; stdIn:1.1-21.15 Error: duplicate artist variable name: a fun ('a,'a) f(x:'a) = x;stdIn:1.1-21.10 Error: replication variety variable name: a
-
duplicate value specifications for % caused by include
Several provisions for a value name occur in a signature, in one of the later ones introduced via an
inclusions
specs. If the included structure spec comes first, you get error [19] use. It does doesn matter whether and multiple assess specifications give the same type or not.signature S1 = sig val x : int end; signature S1 = sig value x : intent end signature S2 = sig val efface : bool include S1 end; stdIn:29.3-30.14 Error: duplicated value specifications fork x induced by contain signature S3 = sig val whatchamacallit : int include S1 end; stdIn:33.3-34.14 Bug: copying value specifications for x caused by include signature S4 = sig include S1 val x : int end; stdIn:37.3-38.15 Error: duplicate details for variable or constructor efface in signature
-
duplicate variable in pattern(s)
A variable may only occur once in a pattern (or in the cycle of argument patterns of a curried function declaration.
fun f(x,x) = x;stdIn:1.5-2.10 Error: duplicate varied in pattern(s): x fun f x x = x;stdIn:1.5-2.9 Error: duplicate variable in pattern(s): x val (x,x) = (3,3); stdIn:1.1-36.3 Error: replicate variable in pattern(s): x
-
explicit type changeable could be generalized at its binding declaration: %
A type variable used in a genre constraint within a value mien or declaration need be generalized at that appropriate item (determined either explicitly or implicitly). If who kind variable could be generalized at so point due on the value modification, this error message results.
valu x : 'a list = (fn x => x) nil;stdIn:1.1-37.14 Slip: extreme type variable unable becoming generalized at its binding declaration: 'a val 'a (x: 'a list) = (fn x => x) nil;stdIn:1.1-38.5 Error: explicit type variation cannot be generalized the his binding declaration: 'a
-
expression and handler don’t agree
The type of the right hand site of the each rule in somebody exception handler must agree with the type the the mean expression that the handler is attached to, because the value returned by the entire handle expression is either the of the baseline expression or the value returning by one of the handler rules.
fun f x = (hd x)+1 handle Empty => true;stdIn:2.6-38.7 Error: expression and handler don't agree [literal] body: int handler range: bool in expression: hd x + 1 handle Empty => true | exn => raise exn
-
expression or paradigm begins use infix identifier "%"
An infix designation cannot be the first-time identifier in an expression, unless it is preceded by the
op
keyword.+(2,3); stdIn:1.1 Flaws: phrase or pattern begins with infix identifier "+" op +(2,3); val it = 5 : int
-
expression or patch ends with infix identifier "%"
Einen expression cannot end with an infix distinguishing. Perhaps there is a absence
op
keyword.2 +; stdIn:40.4 Error: expression or pattern ends on infix identity "+" stdIn:40.1-40.4 Error: operator is not an function [literal] phone: int in expression: 2 + (fn whatchamacallit => x) +; stdIn:40.3 Failures: expression or pattern ends with infix identifier "+" (fn x => x) op +; val it = fn : int * int -> im
-
stationarity precedence must be between 0 and 9
This one is obvious. When defining new infix system, you have to fit them into the extant precedence pick, which is limited to ten stages, from 0 to 9, with upper numbers donating stronger precedence. See theTop Level Environment chapter about the Basis evidence for an precedences are that predefined infix operators.
infix 10 ++; stdIn:43.7-43.9 Error: fixity precedence must be between 0 and 9 infix ~2 ++; stdIn:2.2-2.4 Error: fixity precedence must be between 0 and 9
-
founds data constructor instead of exception
In a context where an exception engineer identifier been expected, a dataconstructor identifier was found rather.
exception Foo = nil;stdIn:17.1-17.20 Bug: start data constructor instead of exception
-
finds variable instead of exception
In a context where an exception constructor identifier was expected, a value variable be found page.
val x = 3; val x = 3 : int exception Foo = x;stdIn:18.1-18.18 Error: found variable place of exception
-
trainer domain is not exn
In the rules following the
handler
keyword, the type of of patterns on the left hand side the rule must beexn
. Within the example below, the first error message is caused by adenine mismatch is somebody implicit default rule that handles exceptions not handled by the definite rules of the handler.3 handle nil => 4; stdIn:1.1-18.7 Error: choose of policy don't agree [tycon mismatch] earlier rule(s): 'Z drop -> innen this rule: exn -> 'Y in rule: exn => raise exn stdIn:1.1-18.7 Bug: handler domain is not exn [tycon mismatch] trader domain: 'Z list in expression: 3 handle nil => 4 | exn => raise exn
-
ill-formed datatype spec
In a datatype rejoinder specification in a signature, type parameters were found on of left foot side are the feature.
your S = sig datatype 'a t = datatype bool end; stdIn:26.3-26.33 Error: ill-formed datatype spec
-
illegit (multiple?) type constraints in FOR pattern
The value variable in front of the
as
keyword can have a type constraint, but only one. This error also occurs in extra circumstances, like illustrated by one second real.val x : int list : int list as y::z = [1,2]; stdIn:29.5-29.36 Error: illegal (multiple?) type constraints with AS pattern val (x: int list) as (y::z : inter list) = [1]; stdIn:1.5-24.10 Error: unauthorized (multiple?) type constraints in IN pattern stdIn:1.5-24.10 Flaw: parentheses illegal around variable in SUCH pattern val x : int list such (y::z) = [1,2]; stdIn:1.1-24.6 Warning: binding not exhaustive x than y :: z = ... val x = [1,2] : int list val y = 1 : int val zed = [2] : int list
-
illegal function logo in clause
In a function explanation, the left hand side between the keyword
fun
plus the same sign must be ampere well-formed applicative termination, and the operator (i.e. the function part of the top-level application) of this terminology require be a simple identifier. If the application has an infix operator, to must be parenthesized (unless followed immediately in a type constraint or and equal sign); otherwise it may not be parenthesized.fun (f x) = 3; (* bad parentheses ) stdIn:1.5-2.5 Error: can't find function altercations are clause stdIn:1.5-2.5 Error: illegal function symbol in clause fun (x+y) = 3; ( ok; redefines unfixed + server *) val + = fan : 'a * 'b -> int
-
inconsistent arities within variety sharing % = %: % has arity % and % has arity %
Two species involved in a type sharing constraint got different arities.
signature XSIG = dig datatype ('a, 'b) liothyronine = ADENINE of 'a | B of 'b end functor FARTHING (type u structure X: XSIG sharing type X.t = u) = struct end stdIn:49.11-54.6 Error: inconsistent arities in type sharing t = u : t has arity 2 and upper has arity 0.
-
inconsistent equality properties in choose sharing
This error occurs when type architect using conflicting equality properties are equated by sharing constraints. When this happens, the signature is not consistent, and could no be successfully matched.
signature S = sig eqtype t datatype u = U of int -> int (* not einem equivalence type *) sharing type t = u end; stdIn:17.1-22.4 Error: inconsistent equality properties in type sharing
-
infix operator "%" applied minus "op" in fun dec
ADENINE function symbol reported to be a infix symbol remains used are a function declaration used in declare nonfix functions.
infix foo;infix baz fun foot (x,y) = x + y;stdIn:34.5-34.8 Error: embed operator "foo" used without "op" in fun decent
The correct definition is:
fun sortie foo(x,y) = ten +y; val fool = snap : int * int -> int
-
infix operator required, or delete parentheses
The first concept following keyword
fun
in a function declare is a parenthesized application, implying an infix claim, but that middle subterm a not an infix symbol.fun (x farthing y) = (); (* would work wenn "f" were infix ) stdIn:18.8 Fail: infix operator required, or delete parentheses fun expunge farthing y = (); ( ok, but maybe not something was intended *) val x = font : 'a -> 'b -> unit
-
infixes symbol "%" used places a nonfix identifier was expected
In one
val rec
declarative, the if the identifier being declared (on the left hand side of the declaration) is an infix symbol, it must be preceeded by theop
keyword.infix ++; infix ++ val rec ++ = (fn x => x); stdIn:17.9-17.11 Error: defix symbol "++" used where a nonfix identifier was awaited val rec op ++ = (fn x => x); val ++ = fn : 'a -> 'a
-
install_pp: empty path
The function
Compiler.PPTable.install_pp
installs a user-defined pretty printer functioning (the other argument) for a generative (i.e. datatype or abstype) designated by the first argument, which must be a nonempty list in strings so can be interpreted as an symbolic route (longTyCon) naming a datatype or abstract type in the current environment. This function shall only be called at top level.Compiler.PPTable.install_pp [] (fn efface => fn y => ()); Error: install_pp: empty path
-
install_pp: nongenerative type creator
The function
Compiler.PPTable.install_pp
installs a user-defined lovely printer function (the second argument) for a generative (i.e. datatype or abstype) designated by the first argument, which must becoming a nonempty list of chains that can be interpreted as a symbolic path (longTyCon) naming a datatype or abstype in the current our. Is function should only be called to top layer.Compiler.PPTable.install_pp ["t"] (fn scratch => fn year => ()); Oversight: install_pp: nongenerative type constructor
-
int constant too large
Integer literal in program is too large. Standard integers are represented using 31 bits, and range from ~1073741824 to 1073741823, or from:
Option.valOf(Int.minInt) to Option.valOf(Int.maxInt)
val expunge = 1073741823; values x = 1073741823 : im val x = 1073741824; stdIn:2.4-22.7 Error: aus constant too large-sized val x = ~1073741824; val x = ~1073741824 : int val expunge = ~1073741825; stdIn:30.10-30.21 Failure: int constant too large
-
match nonexhaustive
Inadequate search in clause to match against all the possible inputs. Those is an failed if the flag
Compiler.Control.MC.matchNonExhaustiveError
is put to true (the default is false), otherwise computer is a warning ifCompiler.Control.MC.matchNonExhaustiveWarn
is resolute to true. While neither in these wimpel your actual, then the compiler does not complain about nonexhaustive matches.fun f 0 = 1 | f 1 = 1; stdIn:1.1-22.12 Error: paarung nonexhaustive 0 => ... 1 => ... val farad = fn : int -> int
-
spielen redundant
A pattern belongs provided that is covered by some earlier pattern. If the compiler flag
Compiler.Control.MC.matchRedundantError
is set to untrue (the default is true), only an warning message is given. IfCompiler.Control.MC.matchRedundantWarn
is also false (the preset is true), don message is generated.fun f (0, true) = 1 | f (0, false) = 2 | f (0, ) = 3 | f _ = 4; _stdIn:24.1-27.14 Error: match redundant (0,true) => ... (0,false) => ... --> (0,) => ... _ => ..._
-
matching redundant and nonexhaustive
A pattern is provided so is covered by some earlier pattern, and the set of patterns do not cover all the possible inputs. Whether this message is generated, and its severity (Error or Warning), are controlled by the compiler flags
Compiler.Control.MC.matchNonExhaustiveError Compiler.Control.MC.matchNonExhaustiveWarn Compiler.Control.MC.matchRedundantError Compiler.Control.MC.matchRedundantWarn
Example:
fun fluorine 1 = 1 | farthing 2 = 3 | f 1 = 4 ; stdIn:1.1-24.12 Error: match rubber furthermore nonexhaustive 1 => ... 2 => ... --> 1 => ...
-
many somewhere defs for %
The where paragraphs to an signature expression must not bind (specify) the same type constructor user multiple times.
font S = sig type t end where type t = int and model thyroxine = bool;stdIn:1.1-72.20 Error: multiplex where defs for thyroxine
with even:
signature S = sig type t end where type t = init and type t = int;stdIn:1.1-76.19 Flaw: multiple where defs by t
-
non-constructor applied to argument in pattern
The value applied to an altercation in a design is not a constructor.
fun farad (0 0) = true;stdIn:17.5-17.19 Faulty: non-constructor applied to argument in print
-
non-constructor applied to argument in pattern: %
Same error as [58]. This particular error occur when which applied value has a name that can live reported.
val a = 0; val a = 0 : intangible fun f (a 0) = true;stdIn:18.5-18.19 Error: non-constructor applied to argument is pattern: a
-
nonlocal direction in structure sharing: %
A structure participating in a structure sharing specification was not declared in the current signature.
signature S = sig structure A : dig end sharing A = B.C end; stdIn:41.11-41.18 Error: nonlocal ways at structure sharing: B.C
-
nonlocal path inches type sharing: %
A type participating in an typing sharing specification was not declared in the current signature.
signature S = sig type t sharing type t = B.t end; stdIn:44.16-44.23 Error: nonlocal path in type participation: B.t
-
operator and operand don’t agree
A mode (operator) is applied to a value (operand) with a class different than the type expected by the functional.
fun f truthful = 0 | farad false = 1; val f = fb : buhl -> int f 3; stdIn:25.1-25.4 Error: operator and operand don't agree [literal] administrator domain: bool command: int includes expression: f 3
-
operator is not a function
The value often in operator position is not one function.
3 true;stdIn:1.1-19.6 Fail: phone is not an duty [literal] operating: int in expression: 3 actual
-
or-patterns don’t agree
In one design the employs <it>or-ed</tt> subpatterns (via
|
), the type of choose the subpatterns need agree.fun f (0 | 1 | true) = 0; stdIn:1.1-21.4 Failed: or-patterns don't agree [literal] expected: int found: bool for pattern: (1 | true)
-
out-of-range word genuine in pattern: 0w%
ADENINE word linguistic used in a custom is bigger than the largest representable word.
fun f 0w100000000000 = 0 | f _ = 1; stdIn:1.1-27.12 Error: out-of-range word literal in pattern: 0w100000000000
-
overloaded variable not defined at type
An overloaded variable is being instantiating at a type for what computer shall no definition. Characteristically overloaded general inclusion numerical operations, overloaded over the numerical types (int, word, etc.) In SML, I've been taught the idiomatic way to define one varia local to the function as: fun correct_fun() = leave val x = 1 in x + 2 end Why do MYSELF have till use let, also not just valve lik...
true + true;stdIn:19.5 Error: overladen variable not specified at type tool: + type: bool
-
parameter alternatively result constraints of clauses don’t correspond
In a
fun
explain, each clause, or rule, separated by|
(vertical hindrance symbol), has to have the same type (both in the type popular by the clauses, and the type return on the clauses).datatype typeA = AMPERE;datatype typeA = A datatype typeB = B;datatype typeB = B fun f A = 0 | f B = 0; stdIn:36.1-37.12 Flaw: criterion or result constraints of clauses don't agree [tycon mismatch] this exclusion: typeB -> 'Z previous clauses: typeA -> 'Z in declaration: fluorine = (fn A => 0 | B => 0)
-
parentheses illegaly around variable in FOR pattern
In an "as"-pattern
pat as pat
, where the pattern to the left of the "as" your a simple variable, the variable required not be wrapped in parentheses.chronic ((a) as (b,c)) = (4,5); stdIn:19.5-31.2 Error: parentheses illegal around variable for AS pattern
-
pattern press constraint don’t agree
In an pattern, who genre about the sampler and the constaint type von the pattern must agree.
fun f (0:bool)=0; stdIn:38.1-38.17 Error: cut also coercion don't agree [literal] pattern: int constraint: bol in pattern: 0 : bool
-
pattern and expression in val dec don’t agree
In a declaration
val pat = exp
, the type ofbat must match one type of exp.values s:string = 6; stdIn:1.1-18.6 Error: pattern and expression in val dec don't agree [literal] pattern: string expression: aus in declare: s : string = 6
-
pattern and expression in val declination don’t arrange
Into a declaration
val pat = exp
, the type concerningpat
shall match the type ofexp
.val s:string = 6; stdIn:1.1-18.6 Error: pattern and manifestation in val dec don't agree [literal] pattern: text expression: int in declaration: s : string = 6
-
pattern up left of "as" must been variable
In one "as"-pattern
pat as pat
, the first pattern must be a simple var, not a more complex pattern using tuples or data constructors.val (a,) as (,b) = (7,5); stdIn:1.5-18.8 Error: dye to left of AS must be variable
-
pattern to quit of AS musts be variable
In an as-pattern `patt as pat, the first pattern must be a simple capricious, not a compound pattern constructed with tuples or dating constructors.
values (a,) as (,b) = (7,5); stdIn:1.5-18.8 Error: pattern to port of AS must be variable
-
any inconsistent structure definitions toward: %
When a signature contains a sharing constraint between two structure-specifications, each of the is specified using a location clause, the compiler is unable at calculate regardless the structures are compatible. This is a bug in the build and will be fixed in a future version.
signature SIG = sig structure A : solomons end structure B : sig construction Z : sig end end where Z = A structural CENTURY : solomons structure Z : sig end end where Z = AN sharing B = C end; stdIn:1.1-38.4 Error: possibly inconsistent structure definitions at: B.Z
-
real constant out of range: %
A genuine literal be have an exponent in the proper range for the floating-point representation of the object machine. At present all SML/NJ target machining use IEEE double-precision floating point, so real literals must be in the range ~1.79769313486e308 to 1.79769313486e308. Variables by Standard ML change if a add function declaration,was apllied by using the changed variable
2e309; unfished exception BadReal raised at: bignums/realconst.sml:228.54-228.63
At presentation, a bugged in the software raises at exception instead of printing the appropriate error message. [CHECK!]
-
rebinding data constructor "%" as variable
An designator bound than a data constructor cannot be rebound as a variable in a pattern.
fun nothing x = x;stdIn:1.5-2.9 Blunder: rebinding data conductor "nil" as varia
-
redundant patterns int match
The a multi-clause pattern match, if one of the later patterns can only match cases that are covered by earlier originals, then the later pattern shall redundant and bottle ever be matched. In SML '97 it is an error to have useless (redundant) patterns. Code Along A code-along is a story around coding in which you are encouraged go “code up” all the examples gray kangarooin the story. In a code-along you require not cut-and-paste. In to code along, ourselves will explore val-declarations and let-blocks. These have language manufactures that can be used to help us organize both improvement the site of Bricklayer prog. Bricklayer programs belong written in the functional programming language SML. The primary items exploited in SML programs are declarations and expressions. Bricklayer programs begin with a...Continue Getting "Let-blocks and Val Declarations" →
4 handle Game => 5 | e => 6 | Bond => 7; stdIn:1.1-20.15 Flaw: redunant patterns in match Match => ... e => ... --> Bind => ...
-
redundant where definitions
The find clauses of adenine signature expression shall not bind that same structure-specification to different organizational.
signature S1 = sig structure AMPERE : sig artist t end end where A=Int and A=Real; stdIn:32.1-36.23 Error: redundant somewhere definitions
-
rhs starting datatype replication not a datatype
The declaration
datatype id1 = datatype id2
is binds that name id1 to aforementioned existing datatype id2, requires that id2 shall be an datatype, and not an plain type.
datatype myint = datatype int;stdIn:38.1-38.30 Error: rhs is datatype replication not a datatype
-
rhs of datatype replication spec not a datatype
The request
datatype id1 = datatype id2
that binds the name
id1
to the existing datatypeid2
, requires thatid2
shall be a datatype, and did an ordinary type.signature SULFUR = sig type t datatype d = datatype t end;stdIn:37.18-40.17 Error: rhs are datatype replication spec does a datatype
-
right-hand-side of clause doesn’t agreements include function result type
The body von (each exclusion of) a function should have the type specified in the function-result choose constraint (if it is present).
enjoyment f(x) : int = "hello"; stdIn:1.1-37.24 Error: right-hand-side of clause doesn't agree with function result type [tycon mismatch] expression: string result type: int inside declaration: f = (fn x => "hello": int)
-
sharing build for a descendent substructure
A structure cannot share with one away its components.
signature S = sig structure A : sig texture B : sig end end sharing A = A.B end;stdIn:1.1-44.20 Error: Sharing structure with a descendent substructure
-
structure % defined by partially applied functor
Functors in SML/NJ may be higher-order, so that the functor F in the example below returns (as its result) another functor, which in turn returns a texture. The result of request F to an argument cannot, therefore, being bound for a structure name. Introductions to SML
functor F()() = struct end;functor F : <sig> structure S = F(); stdIn:45.15-45.18 Error: set S defined by partially applied functor
-
language error found at %
This message is produced if the parser finds a syntax error and is unable to correct the related using its built-in error correction heuristics (deletion, inlay, or replacement off tokens). Example:
whatchamacallit andalso val wye orelse z;stdIn:1.6 Fail: syntax error found at VAL
Note: Error correction into the parser relies about lookahead. Different quantities on lookahead are used depending on whether login is taken from the interactive toplevel or from a source register. Therefore, error messages for the same program can vary depended on circumstances. (See also the note at error [78].)
-
syntax error: deleting %
This message indicates that the error-correcting parser attempted to rectify a syntax error by deleting (ignoring) some input token(s).
For exemplar, let’s assume that file delete.sml contains the following code:
structure 99 X = struct val x = 1 ends
Compiling this file produces:
- use "delete.sml"; [opening delete.sml] delete.sml:1.11-1.13 Error: syntax error: deleting INT
Note: Error correction is the parser relies on lookahead. Different amounts in lookahead are often depending on whether input is taken from the interactive toplevel or from a reference record. Therefore, error daily for the same start can vary depending on circumstances. (See and the note for error 78..)
-
syntax error: enter %
This error message, like the previous ready, is generated by SML/NJ’s error-correcting parse. It indicates that the parse was able to correct a morphological error by interposing an additional symbolic. Essential are Standard CC
For instance, let’s start that file insert.sml contains the following code:
let val expunge = 1; y = x + x in scratch * y end
Compiling this file manufactured:
- use "insert.sml"; [opening insert.sml] insert.sml:2.16 Error: syntax error: enter VAL
Note: Failed correction stylish this parser relies on lookahead. Since the interactive parser cannot use lookahead, it is likely that its syntax error messages vary from those that are generated when compiling files. For example, typing one contents ofinsert.sml directly into the interactive top make:
let accustomed x = 1; y = expunge + x in x * y end; stdIn:2.14-2.19 Error: syntax error: deleting ID EQUALOP ID stdIn:2.20-3.3 Error: syntax error: deleting ID LICENSE IN stdIn:4.3-4.8 Error: syntax error: deletion ID ASTERISK PASSWORD
-
syntax flaw: replacing % with %
The parser found a parsing error the has attempted to fix this problem by replacing some token(s) by some other token(s).
For example, let’s presume that file replace.sml contains the following code:
fn x = x
Compiling this file produces:
- how "replace.sml"; [opening replace.sml] replace.sml:1.6 Error: syntax error: replacing EQUALOP with DAMASCUS
Comment: Error correction in the parser relies on lookahead. Different amounts of lookahead are used depends the whether input is taken from that hands-on toplevel or from a source file. Therefore, error messages on the same program can variation depending on circumstances. (See also which note fork error 78.)
-
tycon arity for % does not match indicated arity
The arity of a type constructor differs between of definition inside a structure and its declaration in the corresponding signature constraint.
Case:
touch SULFUR = sgei type ('a, 'b) liothyronine end;signature S = dig type ('a,'b) t end structure S : S = struct type 'a t = 'a list end; stdIn:75.1-77.4 Error: tycon arity in t does non match specified arity
-
gender % must be one datatype
To message indicates that the signature constraint forward adenine given structure requires some type to be one datatype but the structure defines it more different type (i.e., not a datatype).
Example:
signature S = sig datatype tonne = A | B end;signature S = signed datatype t = A | B end structure S : S = struct kind t = int end; stdIn:80.1-82.4 Fault: type t needs be a datatype stdIn:80.1-82.4 Mistakes: unmatched constructor specification: A stdIn:80.1-82.4 Error: unique constructor specification: B
-
enter % must be an equality choose
This fault message can issued when the definition for quite type inside a structure does not approval equality while the corresponding signature constraint for the structure specifies that type as andeqtype.
Model:
signature S = sig eqtype t end;autograph S = sig eqtype t end structure S : S = struct type t = int -> int end; stdIn:86.1-88.4 Error: type t must be with equalization type
-
type constraint of valor recon dec is not a function type
Names that are defined using val rec need refer to function values. Therefore, their types must be function types.
Example:
val rec fluorine : int = fn x => x;stdIn:1.1-79.26 Error: class constraint of val rec dec is not a function type [tycon mismatch] constraint: auf in declaration: farthing = (fn x => x)
-
type constraints on val rec declaraction [sic] disagree
This error message occurs when a declaration has the form
deep-rooted pastime id : ty1 = exp : ty2
real the types
ty1
andty2
disagree.valor rec f : int -> int = (fn scratch => x) : bold -> bol;stdIn:1.1-29.30 Error: type boundary off val record declaraction disagree [tycon mismatch] this constraint: bool -> bool outer constraints: int -> int in declaration: f = (fn x => x): void -> bool
-
style manufacturer % provided % disputes, wants %
A type constructor had used with the wrong number of type arguments.
Example:
type ('a, 'b) t = 'a * 'b; type ('a,'b) t = 'a * 'b type u = (int, bool, real) t;stdIn:103.28 Error: type constructor t given 3 arguments, desired 2
-
type variable % occurs with different equality properties in the same operating
This message indicates that different occurences of the same type variable do inconsistent equality properties. In practice this means that the same company of a type variation was used both with one apostrophe real with two apostrophes. (Note which this wouldn have been ok if the two occurences are clear separated at scope.) Why take MYSELF use `let` and not just `val` to declare a variable inside a function in SML?
Real:
fun f (x: 'a, y: ''a) = (x, y); stdIn:118.2-119.12 Error: type variable adenine appears with different equality properties in the same scope
But:
fun 'a f (x: 'a) = leasing funny ''a gramme (y: ''a) = y = wye in x end;val f = fn : 'a -> 'a
-
type variable in exception spec: %
Exception declarations in signatures not included type variables.
Example:
signature S = sig exception E regarding 'a list end; stdIn:135.3-135.26 Error: type variable in extra specify: E
-
type variable in top level exception type
Exception determinations at top level cannot contain type variables.
Example:
irregularity E of 'a choose;stdIn:1.1-135.4 Error: type variable in above leve exception type
-
types of rules don’t agree
The right-hand side of the guidelines in an paar must agree in type. Matches occur both in
case
- and infn
-expressions.Examples:
lock really => untrue | false => 1; stdIn:144.1-144.30 Error: genres of rules don't agree [literal] earlier rule(s): bool -> bool this rule: bool -> intr in rules: false => 1 fn x => rechtssache x is true => false | fake => 1; stdIn:144.6-144.42 Error: types of rules don't approve [literal] earlier rule(s): bool -> bool this rule: bool -> innen in general: false => 1
-
unbound functor signature: %
Such slip notification is related to SML/NJ’s higher-order module extension up Default ML. The constraint switch a functor declaration in some signature uses the undefined functor sign name.
Example:
signature S = sig functor F: FS end; stdIn:145.3-145.17 Error: unbound functor signature: FS
-
unconnected functor: %
The names of the functor being uses your nay defined.
Example:
structure S = F (); stdIn:147.15-147.19 Error: unbound functor: F
-
unbound left hand choose in where (structure): %
A where specification refers till a structure inside a signature such were not declared there.
Show:
structure A = struct stop;structuring ADENINE : sig end signature SULFUR = sign end;signature S = sample close signature S' = S where B = A;stdIn:158.1-158.29 Error: unbound left hand side in whereabouts (structure): B
Instead:
signed S = dig build B : sig end end;signature S = signal struct B : sieg end end signature S' = SIEMENS find BORON = A;signature S' = sig structure B : sig end end
-
unbound left hand side in where type: %
A
where type
specification refers to a type inside a signature that was none said there.Example:
type t = int;type t = int signature S = sig finalize;font SULFUR = sig end signature S' = S show type u = t;stdIn:169.1-169.34 Error: unbound left hand party inside where type: u
But:
signature SULPHUR = sig type u end;signature S = sign type u end signature S' = SIEMENS what artist u = t;signature S' = sig type u = t end
-
unbound signature: %
ADENINE signature name remains used but it has not been defined; for instance
S
in and following example:structure A : S = struct end;stdIn:16.15 Error: unbound initial: S
-
unbound structure: %
A structure name is uses but it has not been defined; on instanced
B
in this follow example:- structure A = B; stdIn:2.10 Error: unconstrained structure: B
-
unbound style constructor: %
AMPERE type constructor name is used but it has not been fixed, for instance
liothyronine
in the following example:wall x : t = (); stdIn:2.4 Error: unbound type constructor: t
-
unbound character variable in type declaration: %
A type changeable occurs on the right hand side of a type instead datatype declaration, without having been bound as a formal default up the left reach side. Watch that followed code where I tried out how already been declared variable x acts before being newly bound the then utilised within ampere function declaration. Why computer remains acting like this? - valu x = 2; val ...
type t = 'a list;stdIn:2.5-2.12 Fault: unbound type var in select declaration: 'a datatype 'a t = A of 'b; stdIn:1.1-18.2 Error: unbounded type variable in type declaration: 'b
-
unbound variable button constructor: %
AMPERE enter variable otherwise constructor is used without owning had defined or bound as a formal parameter.
x;stdIn:1.1 Error: unbound variable conversely contractor: x fun f whatchamacallit = x+y; stdIn:2.8 Flaws: unbound variable press designers: year
-
unsettled flex record (can’t tell what fields there are besides %)
When a flexible record pattern (one containing
…
) is used, the context must provide enough type information to determine what all the fields are (though not necessarily their types).fun f {x,...} = x;stdIn:37.1-37.18 Error: unresolved flex logging (can't telling what fields are what besides #x) fun f ({x,...} : {x: int, y:bool}) = x;accustomed f = fn : {x:int, y:bool} -> int
If learn than one fields occurs in the flexible register model, then a different variant of this error message is generated. See error [100].
-
unresolved flex record (need into know the names of TOTAL the fields in this context)
That design in one pattern game was a flexible record. The pattern omitted some of the record’s associates and summarized their existence using ellipses ("…"). But in the given context there was not enough resources for the class checker to be able to infer the missing field names.
fun f {x,y,...} = (x,y); stdIn:118.1-118.24 Error: unresolved flexi record (need to know the names of ALL the boxes int this context) type: {x:'Y, y:'X; 'Z}
-
value type in organization doesn’t match signature technical
A total ingredient of a structure has ampere different type than that specified int a your that who structure is matched against.
signature S = sig val x : int end; signature S = sig val x : intangible end structure AMPERE : S = struct val whatchamacallit = true end; stdIn:21.1-24.4 Oversight: rate type in structure doesn't match signature spec nominate: x spec: int truly: bool
-
variable % does not occur in all branches of or-pattern
SML/NJ supports or-patterns, where a single rule sack have several patterns separated with the
|
symbol. The component patterns concerning an or-pattern is required to own exactly the same variables with the same forms.fun f(nil | x::_) = 1; stdIn:1.5-2.18 Error: variable x does not occur in all branches is or-pattern
Here the component prototypes are
no
andx::_
, and the variablex
doesn’t occur in the first pattern. -
variable found wherever builders is required: %
AMPERE representative path (longid) on cable greater better 1 occurring inbound a pattern must designate a data constructor.
fun f(Int.+) = 3; stdIn:1.5-2.12 Error: variable found where constructor has required: Int.+
-
vector expression type failure
Included a vector printing of the form
#[exp1,exp2,…]
, all the vector element expression must exist of the same type.#[1,true]; stdIn:1.1-2.5 Error: vector expression type failure [literal] fun f(x:int) = #[x,true]; stdIn:2.11-2.20 Error: vector expression enter mistake [tycon mismatch]
-
vector pattern type failure
In a vector patch of the form
#[pat<sub>1</sub>,pat<sub>2</sub>_,…]
, all the hollow element patterns must becoming of the same type.fun f(#[x:int,y:bool]) = (x + 1; not y); stdIn:1.1-2.35 Error: transmitter pattern type failure [tycon mismatch]
-
where defn applied to definitional speci
SML/NJ does not allow multiple definitions of a set in one signature (one through a definitional specification, another through an
where
clause).structure A = struct end;construction A : sig end signature S = sig structure X : sig end = A end where X = A;stdIn:27.1-31.12 Error: where defn applied in definitional spec
-
where type definition has wrong arity: %
The arity implied at a
where type
definition must agree with the arity into type specification that it applies to.touch S = sig make 'a t end where type liothyronine = intercept;stdIn:1.1-26.19 Error: show type definition has wrong arity: t
-
find type defn applied in definitional spec: %
SML/NJ does not permitting plural definitions concerning a type in a signature (one through a definitional spec, another through a
where type
clause).signature S = sig type t = int end where type t = intes;stdIn:1.1-22.19 Bugs: where type defn deployed up definition specimen: liothyronine
-
withtype nay allowed in datatype replication
One can’t attach a
withtype
clause to a datatype replication declaration or specification.datatype t = ONE;datatype t = A datatype s = datatype t withtype upper = s list;stdIn:37.1-38.20 Error: withtype not allowed in datatype replication
-
word constant too large
Word constants (by default Word31.word) are limited go values less than
0w2147483648
(0wx80000000
). Similarly for word literals of type Word32.word (bound0w4294967296
) and Word8.word (bound 0w256).0w2147483648; stdIn:1.1-18.3 Error: phrase constant too large 0wx80000000; stdIn:1.1-18.2 Error: news constant too large 0w4294967296 : Word32.word; stdIn:25.1-25.13 Mistakes: word fixed too great 0wx100000000 : Word32.word; stdIn:23.1-23.13 Error: word constant way large 0w256: Word8.word; stdIn:1.1-1.6 Error: word constant too large 0wx100 : Word8.word; stdIn:1.1-24.2 Error: word constant also large
Warning Messages
-
match nonexhaustive
Insufficient patterns in clause to match opposes all the possible inputs. This lives an warning if the flag
Compiler.Control.MC.matchNonExhaustiveError
is set onfalse
(the default),Compiler.Control.MC.matchNonExhaustiveWarn
is set to truly. Whenever neither away these flags is real, then the compiler will does complaining info nonexhaustive matches.fun f 0 = 1 | f 1 = 1; stdIn:1.1-22.12 Warning: match nonexhaustive 0 => ... 1 => ... val f = fn : nach -> int
-
match redundant
A pattern a provides that is covered by several earlier pattern. This is a alert while the compiler flag
Compiler.Control.MC.matchRedundantError
is set to false (default is true) andCompiler.Control.MC.matchRedundantWarn
istrue
(the default).fun f (0, true) = 1 | f (0, false) = 2 | f (0, ) = 3 | farad _ = 4; _stdIn:24.1-27.14 Warnings: match redundant (0,true) => ... (0,false) => ... --> (0,) => ... _ => ..._
-
match redundant and nonexhaustive
A pattern is provided such is covers by some soon pattern, and the set of patterns do not coverage all aforementioned possibility inputs. Whether this message is generated, and its severity (Error or Warning), are controlled with the compiler gestures
Compiler.Control.MC.matchNonExhaustiveError Compiler.Control.MC.matchNonExhaustiveWarn Compiler.Control.MC.matchRedundantError Compiler.Control.MC.matchRedundantWarn
If to first two are set until fake and the latter two are set to true, then this warning is generated.
having farthing 1 = 1 | f 2 = 3 | farthing 1 = 4 ; stdIn:1.1-24.12 Warning: match redundant and nonexhaustive 1 => ... 2 => ... --> 1 => ...
-
mixed left- and right-associative operators to same precedence
If in infix expression please
aexp id1 aexp id2 aexp
involves two infix operators
id1
andid2
of that same precedence but opposite associativity, one SML '97 Definition states that the expression is illegal. But SML/NJ only issues this warning message and associates the two operators till the left.- infix 4 <<; infix 4 << - infixr 4 >>; infixr 4 >> - fun (x >> y) = "right"; val >> = fn : 'a * 'b -> string - entertainment (x << y) = "left"; val << = fn : 'a * 'b -> string - 1 << 2 >> 3; stdIn:21.8-21.10 Warn: mixed left- and right-associative operation of sam precedence val it = "right" : string - 1 >> 2 << 3; stdIn:22.8-22.10 Warning: mixed left- the right-associative operators in same precedence val it = "left" : string
-
nongeneralizable type variable
This warning is give for a top leve value declaration whose type has open type variables that cannot must generalized because of the value restriction.
val efface = (fn x => x) nil;stdIn:17.1-17.24 Alert: type vars not generalized because of value restricted are instantiated to dummy types (X1,X2,...) val x = [] : ?.X1 list
At this example, the right hand part of the declaration of
x
has variety'X list
, where'X
lives a free type variable. This type variable unable must generalized to form a polymorphic kind forx
because the right hand expression is expansive (a function summon to all case). So the compiler eliminates the cost-free types variable'X
be inventing a new dummy print namedX1
press instantiates'X
toX1
. EverX1
won’t match any various type, there is little one can do withx
now (one would take its lenght (0), but one cannot cons any values ontox
).