title: Make an error quine!

text:
# Question
Title: Make an error quine!
Your challenge: write a "program", for a language of your choice, that causes the compiler/interpreter/runtime to produce *error output* when compiling/running your program which is identical to your program's source code.

Rules:

* Your program may be specific to a particular version or implementation of your language's compiler/interpreter/runtime environment. If so, please specify the particulars.
* Only standard compiler/interpreter/runtime options are permitted. You cannot pass some weird flag to your compiler to get a specific result.
* The program does *not* need to be syntactically or semantically valid, but I may give a bounty to the best syntactically valid submission.
* The program must not produce any output of its own (e.g. by calling a print or output function). All output generated upon attempting to compile/run the program must originate from the compiler/interpreter/runtime.
* The complete output of the compiler/interpreter/runtime must be exactly identical to your program source code.
* The compiler/interpreter/runtime must generate at least one error message when invoked with your program.

This is a *popularity contest*. Most creative answer, as determined by upvotes, wins. If you can give a *good* case for using a standard loophole, you may do so.

# Answer
> 135 votes
# Ed (1 byte)

All the other solutions thus far are long and ugly. I suppose that is because of the nature of most error messages. But a good error message is elegant in its simplicity. For that, look no further than ed.

```
?

```

Save this to a file called `edscript` and run with `ed < edscript`, or run `ed<<<?`. The result:

```
?

```

The question mark is written to stderr and ed returns 1, so this actually is an error message. I wonder why ed isn't very popular?

# False (0 bytes)

Run with `false filename`. It writes the program's source code (i.e. nothing) to stderr and returns 1. Of course, calling false a programming language is questionable, and the zero byte quine is unoriginal, but I thought I might as well add it. There is probably some interpreter for a language that prints no error messages, and could replace false.

Now I wish this was code golf.

# Answer
> 154 votes
## Windows Command Prompt

```
& was unexpected at this time.

```

# Answer
> 87 votes
## CoffeeScript, syntactically valid

As tested on their website using Chrome or Firefox.

```
ReferenceError: defined is not defined

```

You can replace `defined` with anything that's not a built-in variable, but I thought this version was fun. Unfortunately, `undefined is not defined` in particular doesn't work as a quine.

In CoffeeScript this isn't even a syntax error, because it compiles. This is technically a runtime error in JavaScript, albeit a boring one. CoffeeScript is a likely candidate to produce some more interesting runtime error quines because a lot of funny sentences are valid code. E.g. the above example compiles to

```
({
  ReferenceError: defined === !defined
});

```

# Answer
> 73 votes
# Windows .EXE, 248 bytes

```
The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.

```

No, really. Save as `quine.txt`, then rename to `quine.exe` (or download it here):

# Answer
> 55 votes
# Python

## Spyder

Well, a rather trivial solution for the Spyder IDE is to raise a `SyntaxError`.

**Code and identical output:**

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "/Users/falko/golf.py", line 1
    Traceback (most recent call last):
                         ^
SyntaxError: invalid syntax

```

(Python 2.7.8 with Spyder 2.2.5)

---

## Terminal

An alternative solution for Python started from command line struggles with an unexpected indent.

**Command:**

```
python golf.py

```

**Code and identical output:**

```
  File "golf.py", line 1
    File "golf.py", line 1
    ^
IndentationError: unexpected indent

```

---

## ideone.com

On ideone.com a solution might be as follows. (Try it!)

**Code and identical output:**

```
Traceback (most recent call last):

  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError: SyntaxError: ('invalid syntax', ('prog.py', 1, 22, 'Traceback (most recent call last):\n'))

```

(This is for Python 2. An example for Python 3 is trivial but with 15 lines of "code" rather lengthy.)

---

# General approach:

## How to create your own solution in 2 minutes?

1. Open a new file in an IDE of your choice.
2. Bang your head onto the keyboard in front of you.
3. Compile.
4. Replace the code with the compiler error message.
5. Repeat steps 3 and 4 until the code converges.

I bet such a procedure terminates pretty quickly in most cases!

# Answer
> 47 votes
## \>\<\> - 25 Bytes

```
something smells fishy...

```

In Fish, any bad instruction outputs the error: "something smells fishy...". Since s is not a valid command, it errors immediately.

# Answer
> 42 votes
# Chicken

```
Error on line 1: expected 'chicken'

```

# Answer
> 40 votes
# Whitespace

First I thought this is clearly impossible. But actually it is trivial as well. -.-

```
Fail: Input.hs:108: Non-exhaustive patterns in function parseNum'

```

Try it.

Yeah, my first whitespace program! ;)

# Answer
> 34 votes
# JavaScript

Since different browsers use different JavaScript compilers, they produce different messages. These are, however, rather trivial solutions.

## V8 (Chrome 36 / Node.js)

```
SyntaxError: Unexpected identifier

```

## SpiderMonkey (Firefox 31)

```
SyntaxError: missing ; before statement

```

## Chakra (Internet Explorer 11)

```
Expected ';'

```

# Answer
> 34 votes
## Microsoft Excel

Formula: `#DIV/0!`

Error Message: `#DIV/0!`

In order to enter a formula without using an equals sign, go into Excel Options/Advanced/Lotus Compatibility Settings and enable Transition Formula Entry.

# Answer
> 31 votes
## Commodore 64 Basic

```
?SYNTAX  ERROR

```

When run on the emulator of your choice (or an actual Commodore 64), produces

```
?SYNTAX  ERROR

```

This is, in fact, a syntactically-valid one-line program. The question mark is a shortcut for `PRINT`, and `SYNTAX` and `ERROR` are valid variable names. The error occurs because the parser gets confused by the substring `OR` in `ERROR`.

# Answer
> 23 votes
## Java 8 compilation error quine (12203 bytes)

Generated on windows + mingw with java 1.8.0\_11 jdk, using this command:

```
echo a > Q.java; while true; do javac Q.java 2> Q.err; if [ $(diff Q.err Q.java | wc -c) -eq 0 ]; then break; fi; cat Q.err > Q.java; done

```

May not be the shortest one, may not be the longest one either, more a proof of concept. Works because error output shows at most 100 errors.

```
Q.java:1: error: class, interface, or enum expected
Q.java:1: error: class, interface, or enum expected
^
Q.java:1: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:1: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:1: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:2: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:2: error: ';' expected
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:2: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:2: error: = expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:2: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:2: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:2: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:2: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:3: error: illegal start of type
^
^
Q.java:4: error: = expected
Q.java:1: error: <identifier> expected
 ^
Q.java:4: error: <identifier> expected
Q.java:1: error: <identifier> expected
      ^
Q.java:4: error: ';' expected
Q.java:1: error: <identifier> expected
       ^
Q.java:4: error: illegal start of type
Q.java:1: error: <identifier> expected
        ^
Q.java:4: error: = expected
Q.java:1: error: <identifier> expected
               ^
Q.java:5: error: '(' expected
Q.java:1: error: class, interface, or enum expected
 ^
Q.java:5: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:5: error: ';' expected
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:5: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:5: error: = expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:5: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:5: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:5: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:5: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:6: error: illegal start of type
                      ^
                      ^
Q.java:7: error: = expected
Q.java:1: error: <identifier> expected
 ^
Q.java:7: error: <identifier> expected
Q.java:1: error: <identifier> expected
      ^
Q.java:7: error: ';' expected
Q.java:1: error: <identifier> expected
       ^
Q.java:7: error: illegal start of type
Q.java:1: error: <identifier> expected
        ^
Q.java:7: error: = expected
Q.java:1: error: <identifier> expected
               ^
Q.java:8: error: '(' expected
Q.java:1: error: class, interface, or enum expected
 ^
Q.java:8: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:8: error: ';' expected
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:8: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:8: error: = expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:8: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:8: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:8: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:8: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:9: error: illegal start of type
                                 ^
                                 ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
 ^
Q.java:10: error: <identifier> expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
      ^
Q.java:10: error: ';' expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
       ^
Q.java:10: error: illegal start of type
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
        ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
               ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                       ^
Q.java:10: error: illegal start of type
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                               ^
Q.java:10: error: <identifier> expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                ^
Q.java:10: error: unclosed character literal
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                  ^
Q.java:10: error: ';' expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                    ^
Q.java:10: error: unclosed character literal
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                       ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                                     ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                                           ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                                                      ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                                                                ^
Q.java:11: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:11: error: ';' expected
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:11: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:11: error: = expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:11: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:11: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:11: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:11: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:12: error: illegal start of type
                                      ^
                                      ^
Q.java:12: error: <identifier> expected
                                      ^
                                       ^
Q.java:13: error: = expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
   ^
Q.java:13: error: ';' expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
      ^
Q.java:13: error: <identifier> expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
              ^
Q.java:13: error: = expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
               ^
Q.java:13: error: ';' expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
                  ^
Q.java:13: error: = expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
                               ^
Q.java:13: error: unclosed character literal
  (use -source 1.4 or lower to use 'enum' as an identifier)
                                   ^
Q.java:13: error: unclosed character literal
  (use -source 1.4 or lower to use 'enum' as an identifier)
                                        ^
Q.java:13: error: = expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
                                                          ^
Q.java:14: error: <identifier> expected
Q.java:1: error: = expected
      ^
Q.java:14: error: ';' expected
Q.java:1: error: = expected
       ^
Q.java:14: error: illegal start of type
Q.java:1: error: = expected
        ^
Q.java:14: error: = expected
Q.java:1: error: = expected
               ^
Q.java:14: error: illegal start of type
Q.java:1: error: = expected
                 ^
Q.java:15: error: = expected
Q.java:1: error: class, interface, or enum expected
^
Q.java:15: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
 ^
Q.java:15: error: = expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:15: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:15: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:15: error: = expected
Q.java:1: error: class, interface, or enum expected
          ^
Q.java:15: error: ';' expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:15: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:15: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:15: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:15: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:16: error: illegal start of type
                                           ^
                                           ^
Q.java:17: error: = expected
Q.java:2: error: <identifier> expected
 ^
Q.java:17: error: <identifier> expected
Q.java:2: error: <identifier> expected
      ^
Q.java:17: error: ';' expected
Q.java:2: error: <identifier> expected
       ^
Q.java:17: error: illegal start of type
Q.java:2: error: <identifier> expected
        ^
Q.java:17: error: = expected
Q.java:2: error: <identifier> expected
               ^
100 errors

```

# Answer
> 22 votes
# Bash (32)

Save as file named `x`:

```
x: line 1: x:: command not found

```

When run:

```
>> bash x
x: line 1: x:: command not found

```

# Answer
> 22 votes
# ArnoldC

```
missing IT'S SHOWTIME on first line

```

Paste the code into this compiler.

# Answer
> 21 votes
# TrumpScript - Making PPCG Great Again (TrumpScript)

When trying to run this language on a windows PC, the output is always:

```
Make sure the currently-running OS is not Windows, because we're not PC

```

So when running this program:

```
Make sure the currently-running OS is not Windows, because we're not PC

```

It won't even parse it because the OS check fails, and you get the error message. Examples can be given for Mac as well if anyone wants them haha. God I've wanted to use this in PPCG for awhile now, good that I finally get to.

Full list of errors that can be triggered using environmental specifics:
https://github.com/samshadwell/TrumpScript/blob/master/src/trumpscript/utils.py

---

# Bonus Answer: ArnoldC (ArnoldC)

ArnoldC requires root declaration of `IT'S SHOWTIME`, meaning `main()`, so:

```
WHAT THE FUCK DID I DO WRONG

```

Results in the only error message in ArnoldC...

```
WHAT THE FUCK DID I DO WRONG

```

Which, is actually... hilarious. You have to run it non-verbose though w/o stack traces.

# Answer
> 15 votes
# Z-machine interpreter

```
I don't know the word "know".

```

Test against this popular interpreter. Also there's some sort of mostly harmless game hosted there.

# Answer
> 15 votes
# Mathematica

```
Syntax: "needed." is incomplete; more input is needed.

```

A `.` in *Mathematica* means either a decimal point or function `Dot`. In this case, the `.` appears at the end of an expression and cannot be interpreted.

---

# Answer
> 12 votes
## Julia 0.2.0

Another syntax error found iteratively until a fixed point was reached:

```
ERROR: syntax: extra token "token" after end of expression

```

# Answer
> 11 votes
# AppleScript

```
A identifier can’t go after this identifier.
```

Both `A` and `identifier` can be identifiers, so AppleScript says no.

# Answer
> 10 votes
# C++ (g++)

The file must be saved as `1.pas`.

```
g++: error: 1.pas: Pascal compiler not installed on this system

```

# Answer
> 10 votes
# INTERCALL, 90 bytes

```
Fatal error: A INTERCALL program must start with the mandatory header to prevent golfing.\n

```

Includes a trailing newline at the end. Note that this isn't STDERR, but it was considered to be error output by many, so I posted it here.

This is the "mandatory header":

```
INTERCALL IS A ANTIGOLFING LANGUAGE
SO THIS HEADER IS HERE TO PREVENT GOLFING IN INTERCALL
THE PROGRAM STARTS HERE:

```

# Answer
> 10 votes
# Pepe, 9 bytes

```
RRRERROR!

```

Link to interpreter (paste the code above, permalink removes the `!` and `O`)

**Explanation:**

The interpreter ignores characters other than `R`,`r`,`E`,`e` so the code is:

```
RRRERRR

```

Now to explain:

```
  RE    # Push 0
RR      # (RR flag: doesn't exist)
    RRR # There is no command RRR, so output RRRERROR!

```

# Answer
> 9 votes
# C

I applied the method of repeatedly copying the error messages to the source. It converged in 2 cycles. Compiled on OSX 10.9 with 'cc -c error.c'.

```
error.c:1:1: error: unknown type name 'error'
error.c:1:1: error: unknown type name 'error'
^
error.c:1:6: error: expected identifier or '('
error.c:1:1: error: unknown type name 'error'
     ^
2 errors generated.

```

Note: This is not so much an answer as it is a methodology to get one. The result might change depending on your OS or the version of cc you are using.

The exact method to get the result is to execute the instructions

```
$ cc -c error.c 2>out ; mv out error.c ; cat error.c

```

repeatedly until the output stops changing.

# Answer
> 9 votes
# Applescript (in Script Editor)

```
Syntax Error
A "error" can't go after this identifier.

```

# Answer
> 8 votes
# GHCi (a Haskell interpreter/shell)

```
Code.hs:1:1: Parse error: naked expression at top level

```

### Usage:

Write the code in a file named Code and load with GHCi.

A nice fact is that, if the words were actual identifiers, this would be a legal expression (as long as it would typecheck). This is basically due to the fact that `:` is a built in operator, `.` is used for module-qualified names, and whitespace is used to denote function application.

# Answer
> 8 votes
# BBC Basic, 7 bytes (or 0 Bytes)

This is a valid 7 byte entry:

```
Mistake

```

This is the error message produced by the interpreter when it is completely unable to make sense of the code.

On the other hand, this is not:

```
ERROR

```

This is a valid keyword in BBC Basic which is supposed to deliberately introduce an error of a specified code into the program, but the syntax is wrong (no code is given.) Therefore it returns `Syntax error` (which in turn returns `Mistake` when it is run.)

In general the procedure described by Falko in his answer leads to `Mistake` in BBC basic. There are a few exceptions. anything producing the errors`DATA not LOCAL` or `ON ERROR not LOCAL` leads to the famous zero byte quine: an empty source code produces an empty file.

Given that most error messages in BBC basic are lowercase (and therefore not valid keywords) I am pretty sure that any invalid input will ultimately lead to one of these possibilities.

# Answer
> 7 votes
### Ruby 2 on Windows

*Code:*

```
error.rb:1: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
error.rb:1: syntax error, unexpected tI...
          ^

```

The code was found by testing and iterating the process over and over until a fix-point was reached. The code must be inside the file `"error.rb"`.

*Demo:*

```
C:\>type error.rb
error.rb:1: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTR
ING_DBEG or tSTRING_DVAR or tSTRING_END
error.rb:1: syntax error, unexpected tI...
          ^

C:\>ruby.exe error.rb
error.rb:1: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTR
ING_DBEG or tSTRING_DVAR or tSTRING_END
error.rb:1: syntax error, unexpected tI...
          ^

```

# Answer
> 7 votes
# C (gcc)

```
error.c:1:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
 error.c:1:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
      ^
compilation terminated due to -Wfatal-errors.

```

Compile with `gcc -Wfatal-errors error.c`.

# Answer
> 7 votes
# CJam 0.6.2

```
Syntax error:
java.lang.RuntimeException: y not handled

```

Try it online.

# Answer
> 7 votes
# x86 assembly

Bytecode:

```
53 65 67 6d 65 6e 74 61 75 69 6f 6e 20 66 61 75
6c 74 20 28 63 6f 72 65 20 64 75 6d 70 65 64 29

```

i.e. the text

```
Segmentation fault (core dumped)

```

Crashes immediately because the second instruction (the first being just "push %\[er\]bx") is

```
insl (%dx), %gs:(%di)

```

which fails because (a) ins cannot take segment overrides, (b) %dx and %di are almost certainly uninitialized, (c) %di is a 16-bit memory address and therefore can't be accessed in long mode, (d) ins is an invalid instruction outside of real mode.

The exact output may vary depending on what system this is run on, but it is likely that it will contain some form of illegal instruction.

# Answer
> 7 votes
# m4 (before 1.4.18-3 Termux patch), Termux, Android 11, 35 bytes

Who said the error had to be caused directly?

```
FORTIFY: %n not allowed on Android

```

Includes trailing newline.

m4 uses a very old version of Gnulib.

Since Android doesn't support `%n` in printf, Gnulib will replace every `printf` function in libc with its own custom implementation.

However, stupidly, said function will still use libc's `snprintf` function internally (which it is supposedly trying to replace because it doesn't work ), and when using it, it attempts to use `%n` every single time it is called, *even if `%n` isn't in the original format string.*

`%n` used to be silently ignored on Android (similar to macOS), but Android 11 made these errors fatal, causing this error to be printed followed by `abort()`.

I used `set +m` to prevent Bash from printing the signal error, and I had to compile from source to undo the -3 patch.

The file itself doesn't matter: m4 is guaranteed to crash no matter what. This includes running with no arguments.

See this Github issue

# Answer
> 6 votes
# zsh (Linux)

`zsh: command not found: zsh:`

Should work with some small changes in just about any other shell.

# Answer
> 5 votes
# CoffeeScript

Fails on first error, so it's fairly easy to do:

```
E:\foo.coffee:1:3: error: unexpected \
E:\foo.coffee:1:3: error: unexpected \
  ^

```

**Demo**

```
E:\>coffee -c foo.coffee
E:\foo.coffee:1:3: error: unexpected \
E:\foo.coffee:1:3: error: unexpected \
  ^

E:\>

```

# Answer
> 5 votes
# Forth

Try it here

This was surprisingly easy to come up with.

```
a : error(-13): word not found

```

# Answer
> 5 votes
# Bash

```
$ bash: bash:: command not found
bash: bash:: command not found

```

# Answer
> 5 votes
# ArnoldC, 28 bytes

```
WHAT THE FUCK DID I DO WRONG

```

This is the only error message in ArnoldC, though you do have to turn off stack traces.

# Answer
> 5 votes
# GNU Make 4.1

```
make: *** No rule to make target 'No', needed by 'make'.  Stop.

```

This is **syntactically valid**:

* Make tries to evaluate the target named `make` (first target is the default),
* which depends on the target named `No`,
* which it has no rule for.

# Answer
> 5 votes
# Malbolge, 32 bytes

```
invalid character in source file

```

Try it online!

# Answer
> 5 votes
# Piet, using npiet interpreter

```
cannot read from `Error.txt'; reason: unknown PPM format

```

Save as 'Error.txt' and put it in the same folder as the npiet executable. If you want to golf, you can of course choose a shorter filename and adjust the code to match.

# Answer
> 4 votes
# Lua

Code:

```
lua: ERROR.lua:1: function arguments expected near '.'

```

It seems fairly easy to do with lua. I also modified it to work on ideone.com as:

```
luac: prog.lua:1: function arguments expected near '.'

```

Try it.

# Answer
> 4 votes
# Rebol

Interestingly, the error message here parses as symbols/tokens:

```
x
** Script error: x has no value
** Where: do either either either -apply-
** Near: do intern code

```

So despite looking error-like, it could be made a valid Rebol program if you gave all the words meanings.

However if you wanted an error at the parse phase vs. a runtime error in the code, the program/error could be:

```
1A
** Syntax error: invalid "integer" -- "1A"
** Where: to case load either either -apply-
** Near: (line 1) 1A

```

So given that distinction is possible, you can do fun things if you redefine `**` from exponentiation into something else (which I can't think of how to make useful for this particular challenge, given it's a quine.)

*(Note: Trying to abuse it for a trick uncovered a peculiarity of what happens when `**` (an infix operator) is redefined and then used immediately after. I tried:*

```
**: function [:a :b :c :d :e :f] []
** Syntax error: invalid "integer" -- "1A"
** Where: to case load either either -apply-
** Near: (line 1) 1A

```

*My goal was to override the `**` so that it would accept its arguments unevaluated. That way `** Syntax error: invalid "integer" -- "1A"` (or whatever) would not attempt to assign `invalid` to `error`, but pass the symbols to `**`. But because `**` is infix it attempted to raise the function body to the power of `Syntax` prior to the completion of the assignment of `**:`.*

*It can be remedied by putting any token between the `[]` and the `**`. But it helps to remember how your language evaluator works. :-P)*

# Answer
> 4 votes
## R (GUI)

```
Error: unexpected symbol in "Error: unexpected symbol"

```

The issue here is replicating the `"`, which causes the error message to change from `unexpected symbol` to `unexpected string constant`. Pretty much any error R throws will have the form `Error: <something> in "<bad code>"`, so you will pretty much *always* have to contend with the quoting. I tried this several other ways and always ended up falling back here.

# Answer
> 4 votes
**Pyth**

```
    s_push: parser stack overflow
Traceback (most recent call last):
  File "pyth.py", line 752, in <module>
    exec(code_to_remove_tools + py_code_line, environment)
MemoryError

```

Try it online!

# Answer
> 4 votes
# Javascript (Chrome/V8), ~~65~~ ~~41~~ 39 Bytes

```
Uncaught =u=_=>{throw`=u=${u};u()`};u()

```

Try it online!

# Answer
> 4 votes
**Python 3, 28 bytes**

```
SyntaxError: invalid syntax

```

# Answer
> 4 votes
# Triangularity, 46 bytes

```
I smell no triangularity. YOU SHALL NOT PASS!

```

Try it online!

The language requires programs to be in the form of a triangle. If not, it denies you the gate to programming in the world of triangles. It will not let you pass.

# Answer
> 4 votes
# Rust v1.45.2 (via Rust Playground)

Code (1126 bytes):

```
error: unknown start of token: `
 --> src/lib.rs:1:32
  |
1 | error: unknown start of token: `
  |                                ^
  |
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
  |
1 | error: unknown start of token: '
  |                                ^

error: unknown start of token: `
 --> src/lib.rs:4:36
  |
4 | 1 | error: unknown start of token: `
  |                                    ^
  |
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
  |
4 | 1 | error: unknown start of token: '
  |                                    ^

error: character constant must be escaped: '
 --> src/lib.rs:7:56
  |
7 | help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
  |                                                        ^

error: unterminated character literal
 --> src/lib.rs:9:36
  |
9 | 1 | error: unknown start of token: '
  |                                    ^

error: aborting due to 4 previous errors

error: could not compile `playground`.

```

Try it online (error message might differ in future versions of the language, though)

Compile errors in Rust all start with "error:", so copy/pasting the errors into the source a bunch of times eventually leads to these error messages. Default settings for the Rust Playground were used. That means 2018 edition, stable branch, and debug mode. I don't know what the target triple is.

# Answer
> 4 votes
# Vyxal, 42 bytes

```
slice expected at least 1 arguments, got 0

```

Try it Online!

# Answer
> 3 votes
# Go

Another fairly easy one using the "general approach" provided in the other answer. I still like my JavaScript ones better.

```
can't load package: package :
prog.go:1:1: expected 'package', found 'IDENT' can
prog.go:2:2: invalid package name _

```

Try it.

# Answer
> 3 votes
## Lua (console), 35 bytes

This is what you get in the Lua console with the usual iterative approach:

```
stdin:1: '<name>' expected near '1'

```

which is a bit shorter than the one obtained for putting the code in a file.

# Answer
> 3 votes
# ksh

```
$ ksh: ksh::  not found.
ksh: ksh::  not found.

```

# Answer
> 3 votes
# Perl

```
syntax error at quine.pl line 2, at EOF
Execution of quine.pl aborted due to compilation errors.

```

Replace `quine.pl` with whatever you named the file and enjoy.

# Answer
> 3 votes
# Java, in Eclipse

```
Syntax error on tokens, delete these tokens

```

# Answer
> 3 votes
# Factor

```
No word named "No" found in current vocabulary search path

```

Guess what it prints?

```
No word named "No" found in current vocabulary search path

```

# Answer
> 3 votes
# Processing IDE

Probably the friendliest error message I've ever seen.

```
Syntax error, maybe a missing semicolon?

```

### Result

Technically this is cheating a bit because the pane below it prints `expected SEMI, found 'error'`. Unfortunately the word `error` is written in single quotes, so trying to copy that into the source of the program causes it to spit out a massive "Badly formed character constant" error... which does not include *any* singly-quoted words allowing for it to quine itself.

# Answer
> 3 votes
# SmileBASIC

```
NEXT without FOR in 0:1

```

Whenever the pre-run parser encounters a `NEXT` which isn't paired with a `FOR`, it produces the error `NEXT without FOR in slot:line`. Here, the code is in slot 0 and on line 1.

# Answer
> 3 votes
# A Pear Tree

```
a partridge

```

Try it online!

Almost every program (that isn't very long) prints `a partridge` in A Pear Tree.

One of the goals of the language was to be good at challenges; as such, it tries to find a substring of the program that has a very specific property that rarely occurs by chance, and starts running the program there. If it can't find an appropriate entry point, it prints an error. The actual text of the error message was chosen for the *The Twelve Days of Christmas* reference. (Actually, the design for the language worked the other way round; the main goal was to have a language which errored out on almost any source code, so that it would make the reference in question, so I set about trying to work out what sort of language design would naturally end up doing that.)

# Answer
> 3 votes
# (t)csh

```
Unmatched '.

```

The trailing newline is needed to produce an *exact* match. Run it with `csh quine.csh` (or just type it into the shell, that works too).

# Answer
> 3 votes
# Cubically, 94 bytes

```

Notepad: 0

   000
   000
   000
111222333444
111222333444
111222333444
   555
   555
   555

```

There are newlines at the start and end. (Cubically automatically dumps its memory to STDERR when the program finishes.)

Try it online!

# Answer
> 3 votes
# Rust, ~~323~~ ~~166~~ 164 bytes

Call your program `a.` and use `rustc a.`.

```
error: unknown start of token: \
 --> a.:1:32
  |
1 | error: unknown start of token: \
  |                                ^

error: aborting due to previous error

```

# Answer
> 3 votes
# Pip, 71 bytes

code and error:

```
R is not a unary operator
Fatal error while parsing, execution aborted.

```

also:

```
Hit end of tokens while parsing expression
Fatal error while parsing, execution aborted.

```

Try it online!

# Answer
> 3 votes
## Setanta, 97 bytes

```
Eisceacht ar líne 1: Suíomh 19: Ag súil le uimhir, téacs, bool, athróg, liosta, nó gníomh.

```

Try it here!

# Answer
> 3 votes
# Grok, 20 bytes

```
You don't grok Grok.

```

Try it Online!

Grok has only one error message, and one of the ways to trigger it is to try to execute an invalid command. In this case, `oun'tgrG.` are all invalid commands, so when the execution reaches the first `o`, it errors out, printing the source code.

# Answer
> 3 votes
# Desmos

`Sorry, I don't understand the '"' symbol.`

https://www.desmos.com/calculator/q0w3njcgxe

# Answer
> 3 votes
# Python 3, 105 bytes

```
  File ".code.tio", line 1
        File ".code.tio", line 1
        ^
IndentationError: unexpected indent

```

Try it online!

# Answer
> 2 votes
# Befunge on Wasabi v1.4

There is an interpreter for Befunge called Wasabi, and when an error appears the error message is in the format of a dialog box. This is the program:

```
Unsupported Command : 'U' at (1, 0). Ignore next syntax error(s)?

```

To test, download Wasabi v1.4 and insert the above program.

# Answer
> 2 votes
# MATLAB, 66 bytes

```
Undefined function 'Undefined' for input arguments of type 'char'.

```

This outputs the same to STDERR (shown in the console in red):

This is actually pretty unknown functionality (and it's rarely useful), which is why the MATLAB submission in the "Hello World!"-challenge may be improved.

This works because MATLAB will automatically interpret a command on the form `<word_1 word_2 word_3 word_4>`, with no surrounding brackets, as a function on the form:

```
word_1('word_2')`

```

That is, it calls a function `word_1` and gives the single input argument after the first, and in front of the second space as a string input to that function.

"Real life"-examples that can be used for golfing:

```
disp Hello   % Shorter than disp('Hello')
Hello

disp Hello World!
Hello

nnz variable
ans =
     8

```

Note that it will *always* interpret it as a string, it will not evaluate it:

```
variable = 3;
nnz variable
ans =
     8
nnz(variable)
ans =
     1

```

# Answer
> 2 votes
# NASM for x86: 45 bytes

`e.asm:1: error: parser: instruction expected`

Assemble (or attempt to assemble) with `nasm e.asm`

Just in case:

```
0:beau@beau-Latitude-E6330:[~/asm/q]$ nasm -v
NASM version 2.12.02 compiled on Feb  5 2017
0:beau@beau-Latitude-E6330:[~/asm/q]$

```

# Answer
> 2 votes
# Turing Machine Code, 70 bytes

```
Syntax error on line 1: <current symbol> should be a single character!

```

Try it online!

# Answer
> 2 votes
# Husk, 39 bytes

```
Could not infer valid type for program

```

Try it online! The infamous error that everyone is familiar with. Interestingly, I had trouble finding any other error quines: `Parse error (missing \): ¶` is nearly one in verbose mode, but it outputs `Parse error (missing \): ): ¶¶`.

# Answer
> 2 votes
## Swift

This is a *bit* of a stretch. Bear with me.

The source MUST be encoded as UTF-16. Formatting the following as UTF-16:

```
swift.swift:1:1: error: input files must be encoded as UTF-8 instead of UTF-16
??^@s^@w^@i^@f^@t^@.^@s^@w^@i^@f^@t^@:^@1^@:^@1^@:^@ ^@e^@r^@r^@o^@r^@:^@^@i^@n^@p^@u^@t^@ ^@f^@i^@l^@e^@s^@ ^@m^@u^@s^@t^@ ^@b^@e^@\^@e^@n^@c^@o^@d^@e^@d^@ ^@a^@s^@ ^@U^@T^@F^@-^@8^@ ^@i^@n^@s^@t^@e^@a^@d^@ ^@o^@f^@ ^@U^@T^@F^@-^@1^@6^@

```

where `^@` is emacs-speak for an embedded `NUL` and the `?` characters are genuine ASCII question marks. Outputting to console (`cat` doesn't work, being ignorant of UTF16):

`$ iconv -f utf-16 swift.swift`

```
swift.swift:1:1: error: input files must be encoded as UTF-8 instead of UTF-16
??swift.swift:1:1: error: input files must be encoded as UTF-8 instead of UTF-16

```

and compiling:

`$ swiftc swift.swift`

We get:

```
swift.swift:1:1: error: input files must be encoded as UTF-8 instead of UTF-16
??swift.swift:1:1: error: input files must be encoded as UTF-8 instead of UTF-16

```

As desired.

CAVEATS:

* The terminal is taking the 16-bit header BOM `\xFF\xFE` in the error message from `swiftc` and degrading it as ASCII `??` in the console.
* When the swift compiler is run *in an Emacs shell*, the terminal settings *do not* process the unprintable ASCII characters, instead rendering them in Octal.
* When the source is rendered *in an Emacs buffer*, which is UTF-16 aware, the first line appears correctly, and the ?? appears correctly, and but the remaining characters are shown interspersed with `NUL` literals rendered as `^@`.
* `cat` in the Terminal doesn't work either, being unaware of UTF-16.
* A UTF16-aware output utility is needed: `iconv -f utf-16 swift.swift`, where the terminal emulator subsequently discards the interspersed `NUL` characters on the second line.
* In MacOS, `swiftc` leverages terminal capabilities to produce bold and color escape codes. To avoid this ambiguity, you can use `export TERM=dumb`.

I'm claiming it's a quine as long as the source is rendered with a UTF-16 aware output utility and a terminal that discards ANSI formatting, NULs, and degrades unprintable characters to `?`.

*USING TextEdit*

You can also make a more visually convincing argument using `˛ˇ` in place of `??` where you keep the input as UTF-16 and let Swift output the (invalid) UTF-8 output with `swiftc swift.swift > out 2>&1` and open `out` in TextEdit. Side by side, the input and output indeed are rendered identically. No less dubious under the covers, but looks *a lot* less dubious.

So...when you say *exactly identical*, what *exactly* do you mean?

If the output must be re-usable as the input, the quine constraint is indeed violated. And if you argue it's OK to cycle the UTF8 compiler output *back* to UTF16 source, that seems promising, but doesn't work because the output of `swiftc` is neither valid UTF-8 *nor* UTF-16: it is not valid to embed the BOM header midstream in either encoding. It's just terminal poo. Having fun yet?

It's an interesting foray into encoding and terminals, at the least!

# Answer
> 2 votes
# Agda, 95 bytes

After a few attempts, I finally found a solution in my favorite dependently typed language! Agda includes the full filename in place of `error.agda` on lines 1 & 2.

```
error.agda:3,1-1
error.agda:3,1: Parse error
)<ERROR>
<ERROR>
<ERROR>
<ERROR>
<ERROR...

```

Save file as `error.agda` and prepend the full filepath on those first two lines for a local answer, or here: Try it online!

# Answer
> 2 votes
# TI-Basic, 24 bytes

```
ERR:SYNTAX
1:Quit
2:Goto

```

lowercase characters outside strings are a syntax error

# Answer
> 2 votes
# Desmos, 41 bytes

```
Sorry, I don't understand the '?' symbol.

```

Try It On Desmos!

Hover over the danger sign to view the error message.

There could be something shorter but I don't have time to go through every single error out there in Desmos lol.

# Answer
> 2 votes
# Desmos

```
Sorry, I don't understand the '&' symbol.

```

Go to desmos.com/calculator and paste in the "code".

# Answer
> 2 votes
# Taxi

```
error: parse error: likely incomplete statement

```

Try it online!

# Answer
> 1 votes
# Cobra

```
test.cobra(1): error: Expecting use, assembly, namespace, class, interface or enum, but got "test".
Compilation failed - 1 error, 0 warnings
Not running due to errors above.

```

# Answer
> 1 votes
# C++

(Using Apple LLVM in Xcode)

```
Unknown type name 'Unknown'
Expected ';' after top level declarator

```

# Answer
> 1 votes
# Loader (using the official Java interpreter):

These should be run from a module named `main` in order to produce the exact error messages given here.

**This works in the most recent version of the interpreter:**

```
Error: Could not evaluate expression Error (module main, line 1)

```

Explanation:

`expression:statement` is a conditional. The interpreter doesn't even syntax check the stuff to the right of the colon (if it did, we'd get a different error message) unless the stuff on the left evaluates to a nonzero value. However, as "Error" is an illegal expression, the interpreter can't evaluate it, exiting the program with this error message.

**In some earlier interpreter versions, this would work instead:**

```
Exception in thread "main" java.lang.RuntimeException: Could not evaluate expression Exception in thread "main" java.lang.RuntimeException (module main,line 1)
    at Loader.expr(Loader.java:183)
    at Loader.load(Loader.java:201)
    at Loader.main(Loader.java:249)

```

# Answer
> 1 votes
## ChucK

Here's my contribution:

```
[chuck]:line(1).char(8): syntax error

```

This works if you first type it into the editor, save it as "chuck", and then run it once. If you run it another time the number in `char()` goes up by eight.

ChucK can be downloaded here.

# Answer
> 1 votes
# CJam

```
Syntax error:
java.lang.RuntimeException: y not handled

```

# Answer
> 1 votes
## Straw

```
/opt/straw/straw.rb:108:in `initialize': no implicit conversion of nil into String (TypeError)
    from /opt/straw/straw.rb:108:in `new'
    from /opt/straw/straw.rb:108:in `step'
    from /opt/straw/straw.rb:225:in `run'
    from /opt/straw/straw.rb:254:in `<main>'

```

Try It Online!

# Answer
> 1 votes
# JavaScript

```
Uncaught SyntaxError: Unexpected identifier

```

Throws a generic `Unexpected identifier` error (in Chrome, at least) because it doesn't recognize `Uncaught` as an identifier.

# Answer
> 1 votes
# Codelike, 36 Bytes

```
Error at (1,1): Unknown character: E

```

Try it!

# Answer
> 1 votes
# Ada

```
test.adb:1:01: compilation unit expected

```

Really just make an ada file, toss it at the start as above and compile with `gcc filename.adb -c`.

# Answer
> 1 votes
# ForceLang

Works in the latest version of the reference implementation as of the time this answer was written.

```
Exception in thread "main" lang.exceptions.IllegalInvocationException: Exception is not a function.
    at lang.ForceLang.parse(ForceLang.java:52)
    at lang.ForceLang.main(ForceLang.java:129)

```

# Answer
> 1 votes
# Python 3.5

Note: the source file should be named "1" for this to work

```
  File "1", line 1
    File "1", line 1
    ^
IndentationError: unexpected indent

```

# Answer
> 1 votes
## GW-BASIC (least: 12 bytes)

```
Syntax error

```

Inspired by the Commodore 64 BASIC answer. Knocked off 2 bytes because IBM and DOS are better than Commodore :P You can download an emulator for GW-BASIC.

```
NEXT without FOR

```

Since GW-BASIC is a line-based language, it only evaluates the first instruction after a newline or colon `:`. Therefore, it reads `NEXT` and automatically fails it didn't read a `FOR`.

## Apple \]\[ BASIC (13 bytes)

```
?SYNTAX ERROR

```

Woo, 1 less byte than the Commodore answer because the old Apples could beat a Commodore anyday :P

## QBasic (43 bytes)

```
Parse failed: Syntax error at 1:1: Token(:)

```

Might be cheating because it only works on the first line.

## Applesoft BASIC (69 bytes)

```
ParseError: Syntax error: Expected line number or separator in line 0

```

Also only works on the first line...

# Answer
> 1 votes
# sed

By using this general approach, I have converged on several sed error quines. This may not work in your sed, in which case, you're using the wrong sed, and therefore would you please acquire necessary, error-quining sed.

Try it online! This version works in TIO, and probably not anywhere else. Open the "Debug" panel to see the error.

Where `sed` is macOS's default `sed`, and `gsed` is a GNU `sed`.

# Answer
> 1 votes
# Recursiva, 7 bytes

```
Error!

```

Try it online!

# Answer
> 1 votes
# Ly

```
Error occurred at program index 3, instruction o (zero-indexed, includes comments)
EmptyStackError: cannot pop from an empty stack

```

Demo (using official compiler)

This program makes use of the `o` in "Error", the first instruction character in the error message that produces an error. (apparently `r` does nothing with an empty stack)

When a stack is not empty, `o` takes the top entry off the selected stack and outputs it as ASCII; `EmptyStackError` occurs when the selected stack is empty. So when Ly runs into this `o`, it causes this error, since we haven't given the stack anything yet.

# Answer
> 1 votes
# VB.Net, 32 Bytes

Create a new, empty project named 'A'. Set the startup object to "Sub Main" (it's a drop-down option). Create a new class called anything. Delete everything from the class and copy/paste the following:

```
'Sub Main' was not found in 'A'.

```

This works because a single quote is a comment, so it looks like a blank file :D

# Answer
> 1 votes
# ESOPUNK, 38 bytes

```
Invalid instruction INVALID at line 0.

```

# Answer
> 1 votes
# K (ngn/k), 2 bytes

```
'c

```

Try it online!

'c is the response from the console indicating that the variable c is undefined

# Answer
> 1 votes
# MiLambda

```
ERROR_NOHALT

```

Try it online!

Seems like a short solution

# Answer
> 1 votes
# Turing Machine But Way Worse, 258 bytes

```
Traceback (most recent call last):
  File "/opt/tmbww/TuringMachineButWayWorse.py", line 16, in <module>
    i[0], i[2], i[3], i[5], i[6] =  int(i[0]), int(i[2]), int(i[3]), int(i[5]), int(i[6])
ValueError: invalid literal for int() with base 10: 'Traceback'

```

Try it online!

# Answer
> 1 votes
# ZSH (macOS), 20 bytes excluding newline

```
 zsh: bad pattern: ^[

```

# Answer
> 1 votes
# W.Y.A.L.H.E.I.N., 253 bytes

```
Traceback (most recent call last):
  File "/opt/wyalhein/whenyouaccidentallylose100endorsementsinnationstates.py", line 6, in <module>
    seed = int(contents[0])
ValueError: invalid literal for int() with base 10: 'Traceback (most recent call last):\n'

```

Try it online!

whenyouaccidentallyloseahundredendorsementsinnationstates expects a seed on the first line, and `Traceback (most recent call last):` is not a valid number (unless we're talking in base 96, of course, but whenyouaccidentallyloseahundredendorsementsinnationstates doesn't).

# Answer
> 1 votes
# C (tcc), 42 bytes

```
.code.tio.c:1: error: declaration expected

```

Try it online!

# Answer
> 1 votes
# MS SQL (Server version 2012), 64 bytes

```
Msg 2812, Level 16, State 62, Line 1
Incorrect syntax near '16'.

```

# Answer
> 1 votes
# Julia 1.0 (Tio)

Implementation specific, but this one is made to run in Tio.

```
ERROR: LoadError: UndefVarError: syntax: extra token "token" after end of expression
Stacktrace:
 [1] include at ./boot.jl:317 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1038
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] exec_options(::Base.JLOptions) at ./client.jl:229
 [5] _start() at ./client.jl:421
in expression starting at /home/runner/.code.tio:1

```

Try it online!

# Answer
> 1 votes
# Brain-flak

`Error at character 33: Unclosed '(' character.`

Try it online!

# Haskell

```
[1 of 1] Compiling Main             ( .code.tio.hs, .code.tio.o )

.code.tio.hs:1:4: error: parse error on input ‘of’
  |
1 | [1 of 1] Compiling Main             ( .code.tio.hs, .code.tio.o )
  |    ^^
/srv/wrappers/haskell: line 5: ./.bin.tio: No such file or directory

```

Try it online!

# Stack Cats

`Error: invalid character in source code, E | E ,edoc ecruos ni retcarahc dilavni :rorrE`

Try it online!

# Taxi

`error: parse error: likely incomplete statement`

Try it online!

# Hexadecimal Stacking Pseudo-Assembly language

```
/opt/hspal/hspal.rb:69:in `run': Illegal opcode: 170  (RuntimeError)
    from /opt/hspal/hspal.rb:75:in `<main>'

```

Try it online!

# Quarterstaff

```
Traceback (most recent call last):
  File "/opt/quarterstaff/quarterstaff.py", line 142, in <module>
    QuarterstaffInterpreter(open(parser.parse_args().program).read())
  File "/opt/quarterstaff/quarterstaff.py", line 7, in __init__
    self.run(self.parse(program), {}, 0)
  File "/opt/quarterstaff/quarterstaff.py", line 35, in parse
    raise Exception
Exception

```

Try it online!

# Haxe

```
Main.hx:1: characters 0-4 : Unexpected Main
Uncaught exception - load.c(181) : Module not found : .bin.tio

```

Try it online!

# Hasm

```
Error with instruction <internal{PARSE}> on line 0:
    Syntax error or illegal instruction: Error with instruction <internal{PARSE}> on line 0:
Dumping core:

STACK:

OFFSTACK:

HEAP:
    0

```

Try it online!

# Mornington Crescent

```
Traceback (most recent call last):
  File "/opt/mornington-crescent/esoterpret.py", line 123, in <module>
    arguments.stdin, extra)
  File "/opt/mornington-crescent/esoterpret.py", line 41, in use_language
    while not(interpreter.has_execution_finished()):
  File "/opt/mornington-crescent/modules/morningtoncrescent/morningtoncrescent.py", line 50, in has_execution_finished
    raise RuntimeError("You have to end at Mornington Crescent.")
RuntimeError: You have to end at Mornington Crescent.

```

Try it online!

# Muriel

`*** ERROR: muriel: Unknown token '*'`

Try it online!

Just picked some random esolangs from TIO and keyboard hashed until I got an error, then copy + pasted.

# Answer
> 1 votes
# Phooey, 21 bytes

```
Unknown mode for '$'

```

Try it online!

Phooey ignores `Unknown mode for '`, then tries to parse `$'` which is an unknown mode for `$`.

# Answer
> 1 votes
# Fig, 1292 bytes (UTF-8)

```
DEBUG:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "x" is null
    at clojure.lang.Numbers.ops(Numbers.java:1068)
    at clojure.lang.Numbers.incP(Numbers.java:141)
    at fig.compression$fromBijectiveBase$fn__191.invoke(compression.clj:26)
    at clojure.core.protocols$fn__8181.invokeStatic(protocols.clj:168)
    at clojure.core.protocols$fn__8181.invoke(protocols.clj:124)
    at clojure.core.protocols$fn__8136$G__8131__8145.invoke(protocols.clj:19)
    at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
    at clojure.core.protocols$fn__8168.invokeStatic(protocols.clj:75)
    at clojure.core.protocols$fn__8168.invoke(protocols.clj:75)
    at clojure.core.protocols$fn__8110$G__8105__8123.invoke(protocols.clj:13)
    at clojure.core$reduce.invokeStatic(core.clj:6830)
    at fig.compression$fromBijectiveBase.invokeStatic(compression.clj:26)
    at fig.compression$decompress.invokeStatic(compression.clj:39)
    at fig.compression$decompress.invoke(compression.clj:35)
    at fig.compression$decompress.invokeStatic(compression.clj:36)
    at fig.parsing$lex.invokeStatic(parsing.clj:40)
    at fig.core$_main.invokeStatic(core.clj:38)
    at fig.core$_main.doInvoke(core.clj:19)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at fig.core.main(Unknown Source)

```

Try it online!

The tabs sadly disable Fig's scoring system, so this is counted in UTF-8/ASCII. ~~Still no normal Fig quine...~~

# Answer
> 1 votes
# Knight (v2 + `EVAL`) (knight-lang.netlify.app implementation), 32 bytes

```
Error: Unknown identifier 'rror'

```

Try it online!

Different implementations handle errors differently (it is undefined behavior in the official specs), which is why I specified the implementation that I'm using.

Also, this technically only works in version 1.x because `EVAL` is removed as a required function in the v2 official specs, but this implementation has `EVAL` even though it is a v2 implementation, which is why I specified `EVAL` in the header just to be safe.

If `EVAL` wasn't implemented in this implementation, I think something like `Error: No value could be parsed!` would be a valid error quine instead (and it coincidentally turns out to also be 32 bytes).

# Knight (v1.2) (C (gcc) implementation), 21 bytes

```
invalid character 'i'

```

Try it online!

Different implementation, different error messages :)

# Answer
> 1 votes
# gpg (GnuPG) 2.2.40, 157 bytes

Note `error` is followed by a newline.

```
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
gpg: no valid OpenPGP data found.
gpg: processing message failed: Unknown system error

```

## Usage in shell

I don't know if that source is REALLY a program source.

```
cat <<'X' >source
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
gpg: no valid OpenPGP data found.
gpg: processing message failed: Unknown system error
X
gpg <source >stdout 2>stderr
cat stdout
diff source stderr

```

# Answer
> 1 votes
# ACCUMULATOR, 7 bytes

```
Invalid

```

`Invalid` is the only error in ACCUMULATOR. This is because `I` is not a function in ACCUMULATOR.

# Answer
> 1 votes
# xidoc, 66 bytes

```
Error while rendering file
at 2:17-2:18 in []
Command not found:

```

# xidoc, 135 bytes

```
Error while rendering file
at 3:26-3:26
Parse error: Unexpected ']'
3 │ Parse error: Unexpected ']'
  │                          ^

```

Try it (you need to paste in the code)

# Answer
> 1 votes
# Python 3 (IDLE)

```
SyntaxError: incomplete input

```

This surprisingly outputs just itself and nothing else.

# Answer
> 1 votes
# MirBSD pax, 127 bytes.

Includes trailing newline:

```
pax: End of archive volume 1 reached
pax: Cannot identify format. Searching...
pax: Sorry, unable to determine archive format.

```

## Usage

```
$ pax -f quine
pax: End of archive volume 1 reached
pax: Cannot identify format. Searching...
pax: Sorry, unable to determine archive format.
$ pax < quine
pax: End of archive volume 1 reached
pax: Cannot identify format. Searching...
pax: Sorry, unable to determine archive format.
$

```

# Answer
> 1 votes
# (,) 38 Bytes

```
code must be surrounded by parentheses

```

Litterally the only possible one on my current interpreter

# Answer
> 0 votes
# CJam, 12 bytes

```
u not handled

```

When operator doesn't exist, interpreter prints `* not handled`

# Answer
> 0 votes
# Elixir

```
== Compilation error on file e.ex ==
** (SyntaxError) e.ex:3: keyword argument must be followed by space after: ex:
    (elixir) lib/kernel/parallel_compiler.ex:114: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1

```

Put the code in `e.ex` and compile with `elixirc e.ex`. There are also some blank lines in the output (and in the file), but I can't get them to appear on here; S.O. eats them.

# Answer
> 0 votes
# F#

```
e.fs(1,11): error FS0010: Unexpected symbol ':' in implementation file

```

Compile with `fsc --nologo e.fs`. Again, there's an extra blank line I can't properly reproduce here. (Without the `--nologo` flag the compiler wants to announce itself and its version number and display a Microsoft copyright message.)

# Answer
> 0 votes
# Syms, 202 bytes

```
Traceback (most recent call last):
  File "/opt/syms/syms.py", line 196, in <module>
    stack.append(("{"+str(stack.pop())+"}").replace("\\","\\\\").replace("&","\\&"))
IndexError: pop from empty list

```

Try it online! Works on TIO. May not work on your configuration.

# Answer
> 0 votes
# KSH script, 48 bytes

Save as a file named `k`.

```
k[1]: not: not found [No such file or directory]

```

Try it online! Note that TIO saves KSH scripts as `.code.tio`, so it's a bit longer but still the same thing.

# Answer
> 0 votes
# k, oK

Might as well group these answers together, since it's supposedly the same language. I must say, this general approach is quite versatile.

### oK

Every error seems to have a lot of environment-specific information, because, well, JavaScript is behind it all. Try it online!

```
/opt/ok/oK.js:876
    throw new Error("unexpected character '"+text[0]+"'");
    ^

Error: unexpected character ')'
    at Object.parse (/opt/ok/oK.js:876:8)
    at Object.<anonymous> (/opt/ok/repl.js:62:43)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)

```

### k

Notice the space at the bottom. This works in `2016.06.28 (c) arthur whitney` version of `kmac`.

```
a
^
value error

```

# Answer
> 0 votes
**Python 3**

```
  File ".py", line 1
    File ".py", line 1
    ^
IndentationError: unexpected indent

```

# Answer
> 0 votes
# ink, 65 bytes

```
ERROR: 'q' line 1: Empty diverts (->) are only valid on choices

```

Try it online!

Must be saved in a file called `q`, which is why the code on TIO is 7 bytes longer.

# Answer
> 0 votes
# Snowman, 121 bytes

```
SnowmanException thrown at tokenize
  what():  at tokenize: letter operator terminated prematurely?
fatal error, aborting

```

Try it online!

# Answer
> 0 votes
# 33

Very simple. `:` isn't a valid command, so it's easy to make an unrecognised token error quine. The error is just where the `:` is in the code.

```
33 (1:8): Unrecognised token

```

# Answer
> 0 votes
## GNU Smalltalk REPL

REPL is always acceptable, and I only learned the Smalltalk REPL and don't know how to save programs in a file. (I think TIO does not have Smalltalk yet.)

```
stdin:1: expected expression

```

This will work when you start the REPL for the first time.

# Answer
> 0 votes
# Red 0.6.3

```
*** Error: not a Red program!

```

Newline included. Save as a `.red` file and run with `red <filename>.red`.

# Answer
> 0 votes
# Pxem (pxemi.2.min.posixism), Filename: 14 bytes + Content: 0 bytes = 14 bytes.

* Filename (has trailing LF!): `.a B4 .[wxyz]`
* Content: empty.

Try it online!

# Answer
> 0 votes
# PPL, 79 bytes

```
Reference error on line 3, column 3

  a()
  ^

The identifier a is not defined

```

I haven't implemented syntax checking properly, so only reference errors and type errors are thrown (plus syntax checking in rare cases). Pretty simple answer, frankly. Attempts to call the nonexisting `a` function (just `a` without the call does not work because my interpreter does not check for invalid expressions in some cases) I know my language is not very good but I'm too lazy to work on it.

# Answer
> 0 votes
# Snap! (scratchblocks syntax)

```
Hmm...
a custom block definition is missing

```

# Answer
> 0 votes
# JavaScript

Thought I would make an updated JS answer.

Firefox:

```
Uncaught SyntaxError: unexpected token: identifier
```
Google Chrome:
```
Uncaught SyntaxError: Unexpected identifier 'SyntaxError'
```

# Answer
> 0 votes
# Applescript, 70 bytes

`0:2: syntax error: A “:” can’t go after this identifier. (-2740)`

Run with `osascript -e "0:2: syntax error: A “:” can’t go after this identifier. (-2740)"`

# Answer
> 0 votes
# LOLCODE, 43 bytes

```
.code.tio:1: unknown token at: .code.tio:1:

```

Try it online!

# Uiua, 95 bytes <sup>SBCS</sup>

```
Error: Unexpected token |
  at 1:25
1 | Error: Unexpected token |
                            ─

```

Try it online!

# Answer
> 0 votes
# YASEPL

```
ERROR 5 no variable is loaded:(

located at :

```

very simple

# Answer
> 0 votes
# Perl 5, 99 bytes code + 8 bytes file path, 107 bytes

File must be named `>>;/\1/a` to close off the `<-- HERE ... <-- HERE` and to reference the nonexistent group in a regex.

Link is to a Bash test suite.

```
Reference to nonexistent group in regex; marked by <-- HERE in m/\1 <-- HERE / at >>;/\1/a line 1.

```

Try it online!

---
Tags: popularity-contest, quine, error-message
---


title: Qat Equation Solver

text:
# Question
Title: Qat Equation Solver
Qat is a tool that lets you search for words matching a given pattern, often used by crossword and other word puzzle writers and solvers.

In this challenge, you will have to implement a specific part of Qat, namely a subset of the "equation solver".

## Equations

The output of a Qat query depends on the dictionary you use (i.e. the list of words you are pattern matching against) and the pattern you input.

The most basic thing you can do in Qat is define **simple patterns**, which are sequences of symbols which should match some words (similar to regular expressions). In this problem, we will only include two different types of symbols:

* A *lowercase* letter, which just matches that letter
* A period `.`, which can match any letter (equivalent to the regular expression `[a-z]`).

For example, using the base Qat dictionary, the simple pattern `l.......v` matches `leitmotiv` and `lermontov`, so the output is `leitmotiv lermontov`.

(There are many more complicated patterns you can also define, but we'll ignore them for this challenge.)

In Qat, you can also describe **equations**. From the website (description simplified and modified to only use our simple patterns):

> Qat's equation solver is based around *variables*, represented by capital letters from A to Z.
>
> An equation consists of a left-hand side (LHS) followed by an equals sign `=` and a right-hand side (RHS).
>
> The LHS consists of a sequence of variables and simple patterns. The RHS is a simple pattern, which matches any word that fits that pattern \[which is then output as a result\].
>
> **Qat will try to assign strings of characters to the variables so that the whole LHS matches the RHS.**

Multiple equations are separated by semicolons, in which case all of the equations must be satisfied, the solution to each of the equations is shown in sequence. If there are multiple valid solutions, each of them is output in sequence.

### Examples

It's probably easiest to understand with some examples.

Suppose we are using the dictionary `[one two onetwo onesix]`. Then:

* The pattern `A=o..` is an equation which says "`A` must match a three letter word starting with 'o'"; the only option here is `one`, so the output is `one`.
* The pattern `A=o..;A=..e` is an equation which says "`A` must match a three letter word starting with 'o' and also a three letter word ending with 'e'"; the only option here is `one`, so the output is `one one` (because there are two equations).
* The pattern `A=...` says "`A` must match a three letter word"; there are two options here (`one` and `two`), so the output is `one; two`.
* The pattern `A=oneB;B=...` says "`A` must `one` prepended to `B`, where `B` is a three-letter word"; the only option here is that `B` is `two`, making `A` equal to `onetwo`. Thus, the output is `onetwo two`. (Note the solutions to the equations are output in order.)
* The pattern `o..A=ones..` says "look for a sequence of characters `A` where the pattern `o..A` can match `ones...`". The only option in this case is that `A` equals `six`, in which case we find a word in the dictionary which matches both `o..six` and `ones..`; the only solution here is `onesix`, so this produces the output `onesix`.
* The pattern `A=...;B=...;C=AB` says "`C` must be the combination of two three-letter words"; the output is thus `one two onetwo`.

## Challenge

Given a dictionary (i.e. a list of valid words) and a pattern, produce the sequence of solutions to the equations matching the pattern. You can take in the input pattern in any format you want as long as it is reasonable and has a direct mapping to the format described above, and output in any reasonable format.

You can assume that the dictionary contains only strings of lowercase letters and the pattern only contains a sequence of valid equations *which has at least one solution*. You do not need to handle recursive inputs.

## Test cases

| Dictionary | Pattern | Output |
| --- | --- | --- |
| `[one two onetwo onesix]` | `A=o..` | `one` |
| `[one two onetwo onesix]` | `A=o..;A=..e` | `one one` |
| `[one two onetwo onesix]` | `A=...` | `one; two` |
| `[one two onetwo onesix]` | `A=oneB;B=...` | `onetwo two` |
| `[one two onetwo onesix]` | `o..A=ones..` | `onesix` |
| `[one two onetwo onesix]` | `A=...;B=...;C=AB` | `one two onetwo` |

Standard loopholes are forbidden. Since this is , the shortest program wins.

# Answer
> 4 votes
# Python 3.8 (pre-release), 298 bytes

```
from itertools import*
import re
P=product
def F(W,E):
 V={ord(i)for i in E if'@'<i<'['};E=E.split(';')
 for t in P(set().union(*[sum((l:=[i]+[x+i for x in l]for i in s),l:=[])for s in W]),repeat=len(V)):yield from P(*[[c for c in W if re.fullmatch(e.translate(dict(zip(V,t))),c+'='+c)]for e in E])

```

Try it online!

Brute force. Tries assigning every substring from every word to each variable.

# Answer
> 3 votes
# Vyxal, 45 bytes

```
₄↔ƛ⁰kAfnvvV₅¹↔$vZ'ƛ÷Mƛ÷εnh=;A;A;vvh;ÞfUvṄ‛; j

```

Try it Online! (times out) or try a version with only three variables.

Tries all possible substitutions and all possible equation results so it's extremely slow.

# Answer
> 0 votes
# Python3, 776 bytes

Long, but fast.

```
from itertools import*
U=str.isupper
E=enumerate
def f(W,p):
 q=[({},{},p)]
 for d,D,p in q:
  if[]==p:return d,D
  for i,a in E(p):
   if all(not U(j)or j in d for j in a[1]):
    H,K={},{}
    for k in product(*[d[j]if U(j)else[j]for j in a[1]]):
     for w in W:
      if all(A=='.'or A==B for A,B in zip_longest(''.join(k),w)):
       H[a[0]]=H.get(a[0],[])+[w]
       for A,B in zip_longest(a[1],k):
        if U(A):K[A]=K.get(A,[])+[B]
       Q=[(a[0],w,{})]
       for u,o,z in Q:
        if''==u and''==o:K={**K,**{i:K.get(i,[])+z[i]for i in z}};continue
        if u and o:
         if U(u[0]):
          for I,_ in E(o):Q+=[(u[1:],o[I+1:],{**z,u[0]:z.get(u[0],[])+[o[:I+1]]})]
         else:Q+=[(u[1:],o[1:],z)]
    q+=[({**d,**K},{**D,**H},p[:i]+p[i+1:])]
    break

```

Try it online!

---
Tags: code-golf
---