151
\$\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\$
6
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ Commented Jul 28, 2017 at 16:18
  • 1
    \$\begingroup\$ @Dennis I guess that's one way of solving the "OP doesn't edit clarifications into question" problem. \$\endgroup\$ Commented Jul 29, 2017 at 23:52
  • 2
    \$\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\$ Commented Nov 24, 2017 at 21:38
  • \$\begingroup\$ @smartpeople is this: "__main__.CodeException: Raised an &rror." my error or is this:"Raised an &rror." \$\endgroup\$ Commented Dec 25, 2017 at 17:13
  • 1
    \$\begingroup\$ TrumpScript running in China? \$\endgroup\$ Commented Jan 30, 2018 at 6:34

129 Answers 129

1 2 3 4
5
0
\$\begingroup\$

Python, 35 bytes

Pretty simple.

print(a)########################### 

Prints out an undeclared variable then adds a comment to make sure that the error message (NameError: name 'a' is not defined) is shorter than the actual code. I could've probably done better.

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

Whitespace (wspace 0.3), 19 bytes

SSSSL SLS TSTS TLST LLL 

Error: w: divide by zero (18 bytes)

Try it online!

The zero divisor error is the shortest error message produced by the wspace 0.3 reference interpreter (see the yspace project for a survey of other errors). Using mod in place of div would yield an equivalent result. The reference interpreter was written in Haskell, so arithmetic operations are evaluated lazily and it will not panic with divide by zero unless the illegal value is used by an eager instructionβ€”printi in this case. To reach the minimum byte count, push 0 is written as SSSSL and end is appended.

push 0 dup div printi end 

Renaming wspace to w gives a shorter error message.

$ ln -s ~/bin/wspace w $ ./w codegolf/shortest_error.ws w: divide by zero $ ./w shortest_error.ws 2>| wc -c 18 $ wc -c < shortest_error.ws 19 

(This solution is part of the ws-challenges repo)

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

Raku (Perl 6) (rakudo), 38 bytes

die#iaj zav; xbsio la, n v km l s zioa 

When run using raku -e, this produces the 37-byte output

Died in block <unit> at -e line 1 

Attempt This Online!

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

YASEPL, 38 bytes

=p/0+000000000000000000000000000000000 

error message:

ERROR 8 divide by 0:( located at /0 
\$\endgroup\$
0
\$\begingroup\$

Go, 67 bytes

package main func main(){var f string = "aaaaaaaaaaaaaaaaaaaaaaaa"} 

Attempt This Online!

Gives the following error (66 bytes):

# command-line-arguments ../code.go:2:17: f declared and not used 
\$\endgroup\$
0
\$\begingroup\$

Bash, 14 bytes

2>&1 ~|cut -b1 

Try it online!

This may or may not fit the rules, I'm not sure... If manipulating the error message is not allowed, I'll remove it. But I thought it was amusing enough to post.

It works by running ~ as a command to generate an error. But since 2>&1 redirects STDOUT to STDIN, the error is passed to cut -b1 which truncates the output to 1 byte.

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

C (Linux), 19 bytes (but code much simpler)

main ; 

Output:

Segmentation fault 
\$\endgroup\$
0
\$\begingroup\$

Emoji-gramming, 12 bytes

πŸ˜ŠπŸŽ€πŸ“’ 

Error, 69 bytes

πŸ’» ⚠️ ➑️ 🚨 1 ⚠ 🎀 ↔️ πŸ“’ 😊 🎀 πŸ“’ None 

I don't know if the None and the trailing line feed in the output count or not.

The error means that the 🎀 (input variable) and the πŸ“’ (output variable) are in the wrong place.

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ The error message is supposed to be shorter than the code, so you'd need to pad your code to 70 bytes for this answer to be valid. \$\endgroup\$ Commented Aug 6 at 22:15
0
\$\begingroup\$

Swift 5.9.2, 46 41 39 bytes

let heresARemarkablyLengthyIdentifier : 

Try the fiddle!

Error, 45 40 38 bytes (when compiled from standard input)

<stdin>:2:2: error: expected type : ^ 
\$\endgroup\$
1 2 3 4
5

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.