From J Wiki
Jump to navigation Jump to search

Back to: Vocabulary

Error Messages

assertion failure Your assert. line did not produce (a list of all) 1 (true). (More...)
attention interrupt


You interrupted execution with the JBreak icon. (More...)
control error While loading script: bad use of if. else. end. etc. (More...)
domain error Invalid valence: The verb doesn't have a definition for the valence it was executed with. (More...)
Invalid value: An argument or operand has an invalid value. (More...)
Invalid public assignment: You've used both (z=:) and (z=.) for some name z. (More...)
Pun in definitions: A name was referred to as one part of speech, but the definition was later changed to another part of speech. (More...)
file name error nonexistent device or file. (More...)
file number error no file open with that number. (More...)
fold limit your Fold did not terminate when you expected. (More...)
ill-formed name Invalid underscores in a name. (More...)
ill-formed number A word starting with a number is not a valid number. (More...)
index error accessing out of bounds of your array. (More...)
interface error illegal filename or request. (More...)
length error x and y do not agree, or an argument has invalid length. (More...)
locale error You tried to use an expired locale. (More...)
limit error number is beyond J's limit. (More...)
NaN error result is not a valid number. (More...)
nonce error feature not supported yet. (More...)
non-unique sparse elements You attempted an operation on a sparse array that would have required expanding the array. (More...)
noun result was required Verbs, and test blocks within explicit definitions, must produce noun results. (More...) open quote string started but not ended. (More...)
out of memory noun too big for computer. (More...)
rank error operand can't have that rank. (More...)
security violation J has attempted something insecure after you demanded heightened security. (More...)
spelling error You've . or : in the wrong place. (More...)
stack error During debugging: You tried to change the definition of a suspended entity. (More...)
Any time: Too many recursions took place. (More...)
syntax error Sentence has an unexecutable phrase. (More...)
time limit Execution took too long. (More...)
uncaught throw. There was no catcht. block to pick up your throw. (More...)
value error that name has no value yet. (More...)

Form of an error message

The typical form of an error message is

|length error
|   (i.3)    +(i.4)
  • All lines of the error message start with the vertical bar: |
  • 1st line: the kind of error - see table above.
  • 2nd line: the bad phrase, with extra spaces removed and then three spaces installed before the word that failed.

If an explicit entity is executing, its name may be displayed on the first line, e.g.

   foo=: verb define
   foo 1
|syntax error: foo
|       @@

Errors in Definitions

When an explicit definition is created (by executing verb/adverb/conjunction define or 1/2/3 : 0), it is immediately preprocessing with some error checking for

  • illegal inflections like +..., flagged as <spelling errors
  • mismatched cpntrol statements, flagged as control errors
  • invalid words, like 1qs which starts with a numeric but is not a valid number, flagged as ill-formed numbers

These errors display the subline on which the syntax check stopped. (A subline is either an entire line or part of a line starting with a control word and ending before the next control word or end-of-line.) Since the executing primitive is the entire verb define, you must scan the definition yourself to find the line containing the errant word.

Error Detected While Loading Scripts

When an error is detected while loading a script, an additional line is typed giving the name of the script and the line number of the failing primitive:

   load 'a.ijs'
|ill-formed number
|   2 + 1qs
|       ^
||   3     :0''
|[-18] c:\jprograms\a.ijs

This message indicates that the failure is on primitive 3 : 0 on line 18 of script a.ijs. Unfortunately line 18 is the last line of the verb being defined, which is the point at which the system audited the verb. You will have to go through the text of the verb to find the error.

Accessing the error status

Find the error number of the last error that J signalled by using Foreign (13!:11) and find the associated message by using Foreign (13!:12).

You can do this at any time, not only immediately after the error.

   badname_ =: 1   NB. raise a typical error
|ill-formed name: badname_

   13!:11''        NB. error number
   13!:12''        NB. associated error message
|ill-formed name: badname_

Foreign  9!:8 gives the list of all possible error messages

|attention interrupt|break|domain error|ill-formed name|ill-formed number|index error|interface error|...

Select from this list to see which one applies to you, using Foreign (13!:11) and (9!:8)

Note: error number 1 corresponds to the first message in the list, i.e. item 0 .

   (<: 13!:11'') { 9!:8''
|ill-formed name|

You can use these facilities in  try./catch. blocks to analyze errors.

emsg =: verb define
esentence =. 4 }. > {: <;._2 (13!:12) ''
estring =. > (<: 13!:11 '') { 9!:8 ''
'Your lordship''s sentence, ',esentence,', while correct up to a point, may exhibit ',estring,'.'
exec =: verb define   NB. execute the sentence y
  ". y
  smoutput emsg''
  i. 0 0
exec '5 + a:'
Your lordship's sentence, 5    +a:, while correct up to a point, may exhibit domain error.

Defining your own error conditions

You can define your own error conditions by using 13!:8, with error numbers 0 to 255.

The following utility: errif examines the Boolean condition y and signals error number x (222 by default) if (y=1). It does nothing if (y=0).

Strictly speaking: errif returns (i.0 0) if (y=0).

   errif=: 222&$: :([: 13!:8 #~)

   errif 0
   errif 1
|: errif
   13!:11''   NB. show the last error number

Error numbers currently used by J itself are as follows:

 1 attention interrupt
 2 break
 3 domain error
 4 ill-formed name
 5 ill-formed number
 6 index error
 7 interface error
 8 input interrupt
 9 length error
10 limit error
11 nonce error
12 assertion failure
13 open quote
14 rank error
16 spelling error
17 stack error
18 stop
19 syntax error
20 system error
21 value error
22 out of memory
23 control error
24 file access error
25 file name error
26 file number error
27 time limit
28 security violation
29 non-unique sparse elements
30 locale error
31 read-only data
32 allocation error
33 NaN error
34 noun result was required
35 uncaught throw.
36 fold limit

Explanations of individual error messages

Warning.png assertion failure

The result of the sentence following an assert. control word contains an atom that is not 1.

Note: this is a more stringent requirement than for the T-block (T) in if. T do. which disregards all but the first atom of T .

Also, T-blocks can contain more than one sentence, while assert. allows only one.

If you see this error, it does not mean an "error" in the sense of the assert.-sentence itself being badly coded (which anyway would signal a different kind of J error). Rather it means the "failure" of the "assertion(s)" you have chosen to make is something that deserves to be reported as an "error".

This is one way to force an error without needing to invent a sentence that actually fails when it's executed.

Another is by using 13!:8 which allows you to choose the error number and text.

   matinv =: monad define
assert. 2 = #$y [ 'matinv rank error'   NB. (%. needs y to have rank 2)
%. y
   matinv 1 2 3
|assertion failure: matinv
|   2=#$y['matinv rank error'

It is good practice to put text on the  assert. line as shown, so you can see exactly which line failed.

Note in the above example that the  NB.-comment text was not echoed.

Warning.png attention interrupt

Warning.png break

J signals  attention interrupt or  break when you execute JBreak. But it's not logically an error because you've deliberately made it happen.

Warning.png control error (during load)

If  control error is detected when a script is being loaded, it's due to a bad control structure (if./do./end. etc.).

Typical mistakes:

1. Forgetting a component of a control structure such as  do. or  end.

2. Leaving off final period, e.g.  if 0=#y do

3. Using  else. after you've used  elseif.

   foo=: verb define
if. 0=#y do. 'empty'
elseif. 1=#y do. 'one letter'
else. 'good:' ; y
|control error
|   [2]else. 'good:' ; y
|   foo=:    verb define

You must carry on using  elseif. (even if you omit the logical condition):

   foo=: verb define
if. 0=#y do. 'empty'
elseif. 1=#y do. 'one letter'
elseif. do. 'good:' ; y   NB. omitted condition always tests true

Warning.png domain error (invalid valence)

It is a  domain error to execute a verb with a valence (viz. monadic or dyadic) it doesn't have a definition for.

   mo =: monad define   NB. monad only
2 * y
   2 mo 4
|domain error: mo
   dy =: dyad define    NB. dyad only
x * y
   dy 5
|domain error: dy
   mo2 =: 2&* : [:      NB. monad only, the tacit way
   2 mo2 3
|domain error: mo2

Warning.png domain error (invalid value)

The verb isn't meant to handle one of more of its arguments. The error could be an invalid type or an invalid value.

Verbs convert precision as needed.

   2 + 'a'    NB. Can't add characters and numbers
|domain error
   _5 # 1     NB. Can't make _5 copies of y
|domain error
   1: b. _1   NB. Can't find an inverse for this verb
|domain error

domain error can occur during assembly of the final result of a verb, even though the verb executed correctly on every cell, if the results cannot be asssembled into a single array.

   ]a =. 5;'a'
|domain error
|       >a

Each box can be opened, but the results cannot be put into a single array.

Warning.png domain error (invalid public assignment)

Public assignment to a name that has been privately assigned is an error:

   tv =: monad define
nm =. y  NB. private assignment
nm =: y  NB. public assignment
   tv 5
|domain error: tv
|   nm    =:y

The reason is that the public name will not be visible while the private namespace is active.

If you really want to make a public assignment to a privately assigned name, you must use a locative, like this:

   NB. save copies of the arguments this verb is called with
   savexy=: 4 : 0
y__   =: y   NB. arguments x and y behave like privately assigned names.
x__   =: x   NB. x__ is the same as x_base_

Use these (and similar) sentences when debugging an explicit definition.

TIP: If you add extra spaces before =: (as shown above) it makes it easy to find them again, for subsequent removal.

Warning.png domain error (pun in definition)

A name has changed parts of speech and is being referred to in a sentence that expects it to have a different part of speech:

   z =. +:
   a =. z
   a   NB. a refers to z, as a verb
   a 5
   z =. 10  NB. But now z is a noun!
   a 5
|domain error: z
|       a 5

Warning.png file name error

File not found or device not found.

Typical mistakes:

1. Trying to load a script that isn't there

   load 'nosuchscript'
not found: /Applications/j602/nosuchscript
|file name error: script
|       0!:0 y[4!:55<'y'

In this case the verb  load executes a smoutput line telling you the name of the missing file. But if you use built-in file handling verbs like  0!:0 directly then the  file name error message is all you'll see. This doesn't tell you the name of the missing file, which is hidden inside noun: y.

2. Accessing a nonexistent device.

   '' 1!:2 <'q:/file.txt'  NB. I have no Q: disk
|file name error
|   ''    1!:2<'q:/file.txt'

Warning.png file number error

There is no file currently open with that number.

Warning.png fold limit

You executed _3 Z: y to impose a limit on the number of iterations of the Fold. The Fold had been executed at least y times.

Warning.png ill-formed name

Your name doesn't follow the name rules.

Usually this is because of underscores.

Most other bad characters result in  ill-formed number or  syntax error .

   name__name_   NB. Object names in an object locative must not contain underscore
|ill-formed name: name__name_
   name_000_    NB. Illegal numeric locale name
|ill-formed name: name_000_
   a =. <'000'
   name__a     NB. Illegal numeric locale name
|ill-formed name: a
|       name__a

Warning.png ill-formed number

Every word that starts with one of _0123456789 must be a valid number according to the rules for constants. If it's not, J signals  ill-formed number .

J detects an invalid number when you define a verb explicitly. But all J tells you is the starting line of the definition. You have to look right through the verb definition to find the bad character.

File a.ijs contains the text

   vill =: monad define
a =. 5
b =. 6
if. y do. c =. 7t end.     NB. The bad character is: t
d =. 5

When the script is loaded, you will see

|ill-formed number
|   c =. 7t
|        ^
|   vill=:monad     define
|[-5] C:\git\jsource2019\makevs\jdll\a.ijs

The -5 says the failing definition ends at line 5. It is up to you to find the line containing the invalid text. Typical mistakes:

1. Writing scientific notation for a number with (-) instead of (_)

   1 + 1E-5
|ill-formed number
   1 + 1E_5

2. Omitting a space after a number

x =: verb define
if. x > 1do.
|ill-formed number
|   x=:    3 :0

Warning.png index error

You have overstepped the bounds of an array, or you have an argument that is too long or short for its context.

Typical mistakes:

1. Forgetting that a list of length n starts with item 0 and ends with item (n-1)

   1{ 'abc'
   2{ 'abc'
   3{ 'abc'
|index error
|   3    {'abc'

Warning.png interface error

Your sentence resulted in a request to the operating system that was rejected.

   1!:1 <'C:/temp?.txt'   NB. Destination folder OK. but invalid character in filename
|interface error

Warning.png length error

One of these cases has arisen:

  • This verb's x- and y-arguments must agree
  • an argument has an expected size, but you didn't honor it.

Typical mistakes:

1. Forgetting the length of a noun you've assigned earlier

   z=: i.3
   z + 1 10 100
1 11 102
   z + 1 10 100 1000
|length error
|   z    +1 10 100 1000

2. Supplying too long an argument to a verb that operates on each axis of the other argument

Example: the x argument of ({.) or ({)

   1 2 3 {. i. 4     NB. One value of x per axis, but there is only 1 axis
|length error
   (<0 1 2) { i. 4   NB. One value per axis, but there is only 1 axis.  You meant <<0 1 2 or just 0 1 2
|length error

3. Supplying the wrong amount of information to a verb

   (,<2) ;: 3 4 5    NB. (;:) wants x to have 2-4 items
|length error

Warning.png limit error

1. You have used a number that is outside J's limits:

J Limits
Value Maximum Value
Print precision 20
Comparison tolerance 2^_34 (5.82077e_11)

2. You have used a number outside the range of accuracy of a verb

   1 o. 1e16   NB. sin needs some fractional accuracy
|limit error

Oddity: invalid starting point in ;.0 is reported as a limit error.

   (,. 5 0) ]"];.0 i. 4
|limit error

Setting a too-large comparison tolerance generates a domain error.

Typical mistakes: 1. Trying to set a large print precision

   ":!.25 (5.4)
|limit error

Warning.png locale error

You tried to access a numbered locale that does not exist. This is not allowed.

   18!:3 ''   NB. Create numbered locale
   a_8_ =. 5
   18!:55 <'8'   NB. Destroy it
   a_8_    NB. You can't go back to it
|locale error
|       a_8_

Warning.png NaN error

NaN, the IEEE-754 "Not a number", is a "data virus" that produces anomalous results and spreads its corruption through computations it takes part in. It should be avoided wherever possible. A numeric computation that would produce NaN will fail with NaN error.

The operations that would produce NaN are:

  • adding infinities of opposite signs, or equivalent operations (including p., H., and T.
  • *y when y has infinite real and imaginary parts
  • x % y or x ! y when x and y are infinite
  • x ^. y when both x and y are infinite or zero

Warning.png nonce error

The operation you requested is meaningful but not currently supported. So, for the time being (for the nonce), rephrase it.

   s =. $. 3 3 ?@$ 100   NB. Create a sparse matrix
   %. s    NB. Oops, sparse-matrix inversion not supported.
|nonce error

Warning.png non-unique sparse elements

When an operation is performed on a sparse array, it is applied to the elements of the array and also to the sparse element. This is illegal if it would leave the sparse element containing atoms with different values

   ($. 2 2 $ 0) ,"1 (1 2)
|non-unique sparse elements
|   ($.2 2$0)    ,"1(1 2)

Warning.png noun result was required

The result of a verb must be a noun.

   f =: verb define
   f 5
|noun result was required: f
|   +

Also, tests following if., elseif., for., while., whilst., select., case., and fcase. must also end with noun results.

   f =: verb define
if. y > undefinedname do.
  y =. 3 * y
   f 5
|noun result was required
|   y > undefinedname


Sometimes J consistently signals  noun result was required when you execute an explicit definition
whose body consists entirely of good lines.

Maybe the last phrase to be executed defines a verb, not a noun?

To fix this problem, insert:  i.0 0 as the last line (see below).

Typical mistake:

Deliberately assigning a verb inside the body of an explicit definition, and then forgetting to override it with a (dummy) noun before exiting the verb.
NB. anonymous verb in script to customize a platform-dependent verb
3 : 0 ''
if. IFWIN do.
  myverb =: myverb_WIN
  myverb =: myverb_OTHER
i.0 0   NB. don't forget this line, else J signals 'noun result was required'

TIP: If the whole purpose of your verb is to customize one or more verbs for later use, get in the habit of writing  i.0 0 or  empty'' as the last line of the body.

Warning.png open quote

Mismatched quotes.

Typical mistakes:

1. Forgetting to escape a quote inside a quoted string by doubling it.

   a =. 'Casey's Tool Works'
|open quote
|      a =. 'Casey's Tool Works'
|                              ^

2. Applying Do (".) to a string containing an apostrophe -- which J reads as an unmatched quote.

   s =. 'Casey''s Tool Works'
   ". s
|open quote
|   Casey's Tool Works
|        ^
|       ".s

Warning.png out of memory

There is not enough virtual memory to hold the size of noun you've created.

J asks the operating system for memory as needed. It has no control over the amount of memory available. Depending on your system, J may be sharing memory with other tasks.

Typical mistakes:

1. Forgetting that just one floating-point number inserted into an array of integers can double its size.

2. A loop that creates extra values has run out of control.

Warning.png rank error

An argument or operand has an invalid rank. This depends on the details of the verb or modifier being executed.

Note that an invalid rank for an argument of a verb must always be smaller than the rank of the verb, because that is the largest rank the verb itself is presented with.

Typical mistakes:

1. Wrong rank for a throwaway argument

   9!:8 'a'   NB. expects ''
|rank error

2. Wrong rank for a control argument

   (<1 1$a:) { i. 2 3
|rank error
   0 1 ". '34 56'   NB. x must be a scalar
|rank error

Warning.png security violation

When the security level has been set to 1 by executing  (9!:25)1 , all verbs able to alter the environment outside J are prohibited. If you run such a verb then J signals  security violation .

All the prohibited verbs are, or contain Foreigns:

  • the dyads of  0!:n (script execution)
  • 1!:n (file operations) except for 1!:43 (Query Working Directory) and 1!:44 (Set Working Directory)
  • 2!:n (host services)
  • 15!:n (DLLs and memory management).

Warning.png spelling error

J signals this error when

  • you used a non-ASCII character (not in quotes) in a sentence
  • you put a period or colon in a bad place, to make a bad word
  • you use a control word outside an explicit definition.

All inflected words, i.e. ending in period or colon, must be predefined in J.

Typical mistakes:

  1. Spelling a control word wrong.
  2. Adding an extra period or colon.
  3. Using a non-ASCII character (most insidiously, a non-breaking space)
  4. Typing a control structure into the execution window, or in a script outside an explicit definition.

Warning.png stack error (during debugging)

You attempted to redefine a name that is suspended. It is OK to reload the verb that is being executed; debugging will continue using the new text. But it is forbidden to reload any other suspended name.

Warning.png stack error (recursion error)

The maximum subroutine depth is pretty big — 10000 or so. If you exceed that, it is almost certainly because you've had an infinite recursion.

   toodeep =: verb define
toodeep y
   toodeep 4
|stack error: toodeep

Warning.png syntax error (invalid sentence)

Execution of a sentence involves finding executable fragments, executing them, and replacing them with the result of the execution. This is done until all the executable fragments have been executed. There should be a single value left. If not, the sentence contains a syntax error.

Typical mistakes:

1. Putting two nouns next to each other, forgetting that they need an intervening verb

   4 + 5 6   NB. 5 6 is one word, so doesn't need to be joined by ,
9 10
   'five six' =. 5 6
   4 + five six   NB. names need to be joined
|syntax error

2. Using: (noun verb) as if it were a hook (it's not a hook!)

   (5 +) 6
|syntax error

3. Leaving out a verb in a long composition of verbs

   %:@:(+/)@@*:   NB. Oops, 2 conjunctions in a row: @@
|syntax error

Warning.png time limit

The time limit set by 9!:33 was exceeded.

When the time limit is nonzero, it is reduced according to the time taken by sentences. J signals  time limit when the remaining time goes to 0.

Warning.png uncaught throw.

You executed a throw. control word, but there was no catcht. block to handle it. Execution terminates at the point of the throw.

Warning.png value error

You have asked the interpreter to evaluate a name that has not been defined.

There is more to this error than meets the eye.

  • A noun, adverb, or conjunction is evaluated when it is encountered during the right-to-left execution of a sentence.
  • A verb is evaluated
      • when it is executed with its (noun) argument(s) or
      • when you type the name of the verb into the j session window as the only word in a line, whereupon the verb needs to be evaluated for display purposes.

This leaves many situations where undefined verbs do not cause  value error .

Rightly so, since it is important to permit mutually-referencing verbs.

For example, typing this sentence into the J session


will result in  value error because you are asking J to display the value of the undefined name.

But the sentence

   myname =: undefname

will not cause an error because myname is defined to be a reference to undefname . But undefname does not yet need to be evaluated.

J assumes the undefined name: myname is a verb of infinite rank that has yet to be defined.



causes no error because myname has in fact been defined, i.e. in terms of  undefname .

But if you now force the interpreter to use myname

   myname 5
|value error: undefname
|       myname 5

the underlying undefined name: undefname is now exposed.

If you type

   undefname1 undefname2
undefname1 undefname2

... J does not signal  value error because you have not asked J to display the value of either undefname1 or undefname2 .

By default, J assumes  undefname1 undefname2 to be a train of two verbs — which forms a hook. You've asked J to display only the hook (which is a verb). Although this verb consists of references to the two said undefined verbs, neither of them needs to be evaluated just yet.

If it is inside a verb definition, an undefined name is not required to be evaluated for display purposes.

Thus it may escape your notice, even if it appears in a lengthy sentence.

   everb =: 3 : 0
total =. +/ y
undefname1 undefname2
undefname1 undefname2 undefname3
sqtotal =. *: totals
meantotal =. (+/ % #) sqtotal
   everb 5

Every line (except the first and the last) contains undefined names. Thus they're all garbage.
However, the verb works ok. J never signals  value error because none of the bad lines actually executes a verb with an argument. (Arguments must of course be nouns.)

All the bad lines simply create new verbs -- and then do nothing with them.

Important.png REMEMBER:

  • Misspelled words in a verb definition will not always cause J to signal an error.
  • And the verb may even appear to work ok.

Information.png Use the addon: lint to perform a static analysis of name assignment, which will find any undefined names.