135
\$\begingroup\$

Challenge

Write the shortest program that, when compiled or executed, produces a fatal error message smaller than the program itself. The error message may not be generated by the program itself, such as Python's raise. A valid answer must include both the code and the error message. Shortest valid answer wins.

No error message does not count as an error message.

Example (Lua)

Code (46 bytes):

[
--aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Error (45 bytes):

[string "[..."]:1: unexpected symbol near '['
\$\endgroup\$
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ – Dennis Jul 28 '17 at 16:18
  • 1
    \$\begingroup\$ @Dennis I guess that's one way of solving the "OP doesn't edit clarifications into question" problem. \$\endgroup\$ – Ørjan Johansen Jul 29 '17 at 23:52
  • 1
    \$\begingroup\$ Thanks for accepting my answer, which got the most votes; however, this was tagged code-golf, so you should accept this answer, which is the shortest. \$\endgroup\$ – MD XF Nov 24 '17 at 21:38
  • \$\begingroup\$ @smartpeople is this: "__main__.CodeException: Raised an &rror." my error or is this:"Raised an &rror." \$\endgroup\$ – FantaC Dec 25 '17 at 17:13
  • \$\begingroup\$ TrumpScript running in China? \$\endgroup\$ – Stan Strum Jan 30 '18 at 6:34

103 Answers 103

0
\$\begingroup\$

><>, 26 Bytes

Code: "we'refinehereuntilthis!"z

Error: Something smells fishy...

All ><> errors are Something smells fishy...

\$\endgroup\$
0
\$\begingroup\$

JavaScript, 13 bytes

prompt(alert(

Error produced (12 bytes):

Expected ')'
\$\endgroup\$
  • \$\begingroup\$ Which browser? Firefox gives: SyntaxError: expected expression, got end of script \$\endgroup\$ – RuteNL Nov 9 '17 at 13:51
0
\$\begingroup\$

Aceto, 41 bytes

                                        &

Try it online!

Produces __main__.CodeException: Raised an &rror.

The error message is 40 chars, so...

\$\endgroup\$
0
\$\begingroup\$

Julia 0.6 (REPL/-e), 20 bytes

print(factorial(-9))

produces:

ERROR: DomainError:

(assuming stacktraces don't count) which is 19 bytes.


Older answer, 22 bytes:

println(Int(Inf)+0123)

Produces

ERROR: InexactError()

which is 21 bytes.


Trivial answer, 7 bytes (probably falls short of "The error message may not be generated by the program itself, such as Python's raise" requirement):

error()

produces

ERROR:
\$\endgroup\$
0
\$\begingroup\$

Attache, 40 bytes

A Reference Error: Undefined variable!!!

Try it online!

Message (39 bytes): Reference Error: Undefined variable "A"

\$\endgroup\$
0
\$\begingroup\$

Go, 36 bytes

package verylongnamednonmainpackage;

Produces:

go run: cannot run non-main package
\$\endgroup\$
0
\$\begingroup\$

F#, 29 bytes code, 28 bytes error message

let [<EntryPoint>] main a=1/0

Generates the runtime Exception message:

Attempted to divide by zero.

+5 bytes thanks to lukass.

\$\endgroup\$
  • 1
    \$\begingroup\$ The question requires an error message shorter than the program: > Write the shortest program that, when compiled or executed, produces a fatal error message smaller than the program itself. \$\endgroup\$ – lukass Jun 27 '18 at 13:14
  • 1
    \$\begingroup\$ I've no idea why, but I read the question as "longer". Damn. Now that I think about it, that makes more sense as a challenge too... \$\endgroup\$ – Ciaran_McCarthy Jun 27 '18 at 13:17
  • \$\begingroup\$ Golfing the combined length of a program and its longer error message would actually be interesting. Write a longer program to generate a shorter message is a cool tradeoff :) \$\endgroup\$ – lukass Jun 27 '18 at 15:37
0
\$\begingroup\$

SmileBASIC console, 12 11 bytes

?@L*EXP(22)

Error message (8 or 9 bytes):

Overflow

Must be run from the console, otherwise it outputs a line number. Normally errors are formatted like {error} in {slot}:{line}({func}:{arg}), but this error isn't caused by a function and doesn't have a line number so only the error name is shown.

EXP(x) returns e^x, and e^22 is 3584912846.131588. This is outside the 32 bit signed integer range of -2147483648 to 2147483647. Multiplying a string (@L) by this value converts it to an integer, causing an overflow error.

\$\endgroup\$
  • \$\begingroup\$ I'd consider calling the language SmileBASIC (DIRECT), since REPLs and similar environments are considered separate languages. \$\endgroup\$ – snail_ Jun 26 '18 at 20:51
  • \$\begingroup\$ Also, you can get the same error with I%=999E99 for 9 bytes. \$\endgroup\$ – snail_ Jun 26 '18 at 20:52
  • \$\begingroup\$ The console isn't a REPL though. \$\endgroup\$ – 12Me21 Jun 26 '18 at 21:29
  • \$\begingroup\$ "REPLs and similar environments" it's close enough that I'd count it, since it is "type in a statement and it runs" \$\endgroup\$ – snail_ Jun 27 '18 at 4:06
0
\$\begingroup\$

Coconut, 48 bytes

Code:

+
CoconutParsererErrorr: parsing failed (line 1)

Prints error (47 bytes):

CoconutParseError: parsing failed (line 1)
  +

with a trailing newline

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Loader, 50 bytes

load t
This is line not executed because of error.

Assumptions:

  • The program is run from a file with a one-byte name
  • The module named t does not exist.

The error message (assuming you run from a module named m) is:

Error: module t does not exist (module m, line 1)
\$\endgroup\$
0
\$\begingroup\$

C# .NET, 59 bytes

public class P{static void Main(){int je=0;int iee=je/je;}}

Try Online
Produces the following error (58 bytes):

System.DivideByZeroException: Attempted to divide by zero.

(NOTE: I am not counting in the stacktrace that the .NET Compiler generates)

\$\endgroup\$
0
\$\begingroup\$

Python, 30 bytes

import math as ma; ma.sqrt(-1)

Error: ValueError: math domain error (29 bytes)

\$\endgroup\$
0
\$\begingroup\$

GNU Smalltalk, 26 bytes

Create a source file _ with underscores:

__________________________

Running gst _, the error is 25 bytes including ␤:

_:1: expected expression

Underscore was originally mapped to , the assignment operator prior to :=.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.