147
\$\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\$
    – Dennis
    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\$ 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\$
    – MD XF
    Nov 24, 2017 at 21:38
  • \$\begingroup\$ @smartpeople is this: "__main__.CodeException: Raised an &rror." my error or is this:"Raised an &rror." \$\endgroup\$
    – qqq
    Dec 25, 2017 at 17:13
  • 1
    \$\begingroup\$ TrumpScript running in China? \$\endgroup\$
    – Stan Strum
    Jan 30, 2018 at 6:34

123 Answers 123

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

ed, 3 bytes

Note: Most of the answers here are ignoring the trailing newline printed as part of the error message in their count. But I don’t see anything in the question to justify ignoring it, and the author commented that the newline should be included. So unless the question is changed, I’m going to include it.

Code (with trailing newline):

??

Error (with trailing newline):

?

\$\endgroup\$
11
  • 29
    \$\begingroup\$ Actually, this is impossible to beat. :P \$\endgroup\$ Jul 21, 2017 at 20:21
  • 1
    \$\begingroup\$ Can ed do addition and primality testing? Or is that not required for this type of challenge? \$\endgroup\$
    – Stephen
    Jul 21, 2017 at 22:34
  • 4
    \$\begingroup\$ @StepHen Yes, it can do addition and primality testing in unary via the usual regex-with-backreferences trick. \$\endgroup\$ Jul 22, 2017 at 0:57
  • 1
    \$\begingroup\$ Very clever, but '?' isn't fatal. \$\endgroup\$ Jul 27, 2017 at 11:50
  • 2
    \$\begingroup\$ As pointed out in a flag, the error is fatal if the code isn't read from a terminal. Try it online! \$\endgroup\$
    – Dennis
    Jul 4, 2018 at 14:12
58
\$\begingroup\$

C (modern Linux), 19 bytes

Would've done my famous segfault but totallyhuman stole it.

main(){longjmp(0);}

Output (18 bytes):

Segmentation fault
\$\endgroup\$
6
  • \$\begingroup\$ You currently have a higher score than me so... Win-win? \$\endgroup\$ Jul 21, 2017 at 20:23
  • 1
    \$\begingroup\$ Let us continue this discussion in chat. \$\endgroup\$
    – Dennis
    Jul 21, 2017 at 21:48
  • \$\begingroup\$ Are there no other locale with a shorter version (So that you could then use main(){main();})? \$\endgroup\$ Jul 27, 2017 at 13:10
  • \$\begingroup\$ @12431234123412341234123 Not that I know of. Also, main(){main();} is not guaranteed to seg-fault. \$\endgroup\$
    – MD XF
    Jul 30, 2017 at 20:51
  • 1
    \$\begingroup\$ @MDXF There is no guarantee (and with optimization enabled in gcc or clang, it end up in a endless loop or ignore the call). But on Code Golf we need a working implementation not a guarantee. \$\endgroup\$ Jul 31, 2017 at 9:08
57
\$\begingroup\$

Python 2, 35 bytes

import sys;sys.tracebacklimit=000;a

Gives error:

NameError: name 'a' is not defined
\$\endgroup\$
2
  • 18
    \$\begingroup\$ modifying the traceback limit... nice one \$\endgroup\$
    – hyper-neutrino
    Jul 21, 2017 at 19:44
  • 1
    \$\begingroup\$ This is clever! \$\endgroup\$
    – Skyler
    Jul 24, 2017 at 19:37
36
\$\begingroup\$

JavaScript (Firefox), 31 bytes

# This is a comment, right? ...

Throws this error:

SyntaxError: illegal character

Tested in the console of Firefox 54.0.1 on Windows 7.

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

Python 2, 87 79 bytes

-8 bytes thanks to Zacharý and Erik the Outgolfer.

from __future__ import braces
#i am most surely seriously actually totallyhuman

Try it online!

Error message, 78 bytes:

Assuming the code is stored in a file named a.

  File "a", line 1
    from __future__ import braces
SyntaxError: not a chance

This is actually a nice little Easter egg in Python. :D

\$\endgroup\$
6
  • 2
    \$\begingroup\$ You can assume a one-char file name! \$\endgroup\$
    – Adalynn
    Jul 21, 2017 at 19:28
  • 2
    \$\begingroup\$ Assuming a 1-char file name, you can golf to this. \$\endgroup\$ Jul 21, 2017 at 19:36
  • \$\begingroup\$ Heh, nice. - - - \$\endgroup\$ Jul 21, 2017 at 19:40
  • 1
    \$\begingroup\$ But the error message has to be smaller than the program itself... \$\endgroup\$
    – Leaky Nun
    Jul 21, 2017 at 20:06
  • 1
    \$\begingroup\$ If you use IDLE you can get \s\sFile "<stdin>", line 1\nSyntaxError: not a chance which is only 50 bytes [\s is a space and \n is a newline], so you can get a 51 byte program.. \$\endgroup\$
    – boboquack
    Jul 26, 2017 at 8:39
25
\$\begingroup\$

Haskell, 13 bytes

main = (main)

Save as t.hs or another one-character name, compile with ghc, and run. Error message (with trailing newline):

t: <<loop>>
\$\endgroup\$
0
20
\$\begingroup\$

><>, 26 bytes

>>>>>>>>>>>>>>>>>>>>>>>>>:

Try it online!

Every error message in Fish is something smells fishy..., so this just moves the pointer right enough times to be longer than that and attempts to duplicate the top of the stack, which is empty at the time.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ I like it, and it's definately the most fishy of all solutions :-) \$\endgroup\$ Jul 25, 2017 at 16:58
  • \$\begingroup\$ @Xan-KunClark-Davis sigh you had to... :P \$\endgroup\$
    – hyper-neutrino
    Jul 25, 2017 at 17:26
20
\$\begingroup\$

Taxi, 38 21 bytes

Switch to plan "abc".

Produces:

error: no such label

Try it online!

-17 bytes thanks to Engineer Toast

Tries to switch to "abc", which does not exist. You would have [abc] somewhere.

\$\endgroup\$
2
  • 5
    \$\begingroup\$ You can get down to 21 bytes with Switch to plan "abc". producing error: no such label. This might be one of the few code-golf challenges where Taxi beats some traditional languages. \$\endgroup\$ Jul 21, 2017 at 20:00
  • \$\begingroup\$ @EngineerToast thanks, didn't think of that one. \$\endgroup\$
    – Stephen
    Jul 21, 2017 at 20:03
20
\$\begingroup\$

System V shell, 25 bytes

mount /dev/hda1 /mnt/hda1

Error message (23 bytes):

mount: not a typewriter

"Not a typewriter" or ENOTTY is an error code defined in errno.h on Unix systems. This is used to indicate that an invalid ioctl (input/output control) number was specified in an ioctl system call. On my system, in /usr/include/asm-generic/errno-base.h, I can find this line:

#define ENOTTY          25      /* Not a typewriter */

In Version 6 UNIX and older, I/O was limited to serial-connected terminal devices, such as a teletype (TTY). These were usually managed through the gtty and stty system calls. If one were to try to use either of these system calls on a non-terminal device, ENOTTY was generated.

Nowadays, there is naturally no need to use a teletype. When gtty and stty were replaced with ioctl, ENOTTY was kept. Some systems still display this message; but most say "inappropriate ioctl for device" instead.

\$\endgroup\$
3
  • \$\begingroup\$ Please explain... \$\endgroup\$
    – univalence
    Jul 22, 2017 at 17:05
  • \$\begingroup\$ @MegaMan Updated with explanation. \$\endgroup\$
    – MD XF
    Jul 22, 2017 at 17:46
  • 2
    \$\begingroup\$ Upvote for actually enlightening explanation. \$\endgroup\$ Jul 25, 2017 at 17:00
20
\$\begingroup\$

JavaScript (Firefox), 21 bytes

(a=null)=>a.charAt(1)

Error (20 bytes): TypeError: a is null

\$\endgroup\$
2
  • 2
    \$\begingroup\$ D'oh! I knew there was a shorter one... \$\endgroup\$ Jul 21, 2017 at 20:49
  • \$\begingroup\$ I had the same idea, came up with a=null;a.x01234567890 Same amount of bytes \$\endgroup\$
    – RuteNL
    Nov 9, 2017 at 13:43
14
\$\begingroup\$

TrumpScript, 30 bytes

We love NATO!
America is great

Error message:

Trump doesn't want to hear it
\$\endgroup\$
1
  • 3
    \$\begingroup\$ P.S. Error codes are in constants.py \$\endgroup\$
    – Timtech
    Jul 26, 2017 at 12:52
12
\$\begingroup\$

Javascript (V8), 24 bytes

decodeURIComponent('%');

Error, 23 bytes:

URIError: URI malformed

Tested on Nodejs v6.11.0 and Google Chrome v59.0.3071.115.

Try it online!

Note that TIO expands the error message.

\$\endgroup\$
1
  • 5
    \$\begingroup\$ Welcome to PPCG! \$\endgroup\$
    – Stephen
    Jul 24, 2017 at 13:02
11
\$\begingroup\$

QBasic, 11 bytes

There are two solutions of 11 bytes in QBasic, one of which might be golfed further. The shortest error message QBasic has is overflow, and can be triggered as such:

i%=i%+32677

This throws overflow because the max for an integer (i%) is 32676. I couldn't get the 32677 golfed without QBasic auto-casting this to long...

Another error, at 11 bytes, would be out of data. QBasic has DATA statements that store data in the program, which can later be accessed by READ statements. Issuing more READs than DATAs causes the error:

READ a$ '--

Note that the statement is padded with a comment to get it up to the length of the error message. Yes, I have an error message with a shorter program, and a program with a shorter error message ...

\$\endgroup\$
11
\$\begingroup\$

Vyxal, 309 bytes

In this answer, I coded it so that the program errors when executed․
Also, according to code-golf statistics, only a small percentage of people who view my answers actually upvote․ 
So if you enjoy this answer, please consider upvoting - it's free, and you can change your mind at any time․ 
Enjoy the answer․

I request that you imagine Epic Dawn by Bobby Cole is playing while reading this answer.

The Error

Traceback (most recent call last):
  File "C:\Users\61419\Desktop\Vyxal\Vyxal.py", line 867, in <module>
    exec(line)
  File "<string>", line 4, in <module>
  File "C:\Users\61419\Desktop\Vyxal\Vyxal.py", line 592, in VY_int
    return int(item, base)
ValueError: invalid literal for int() with base 10: ''

Explained

This fails immediately on the first instruction it sees: I. It tries to convert the empty input to base 10 (which is impossible)

\$\endgroup\$
2
  • 4
    \$\begingroup\$ PPCG: YouTube edition. 😂 \$\endgroup\$
    – EasyasPi
    Jan 5, 2021 at 14:20
  • \$\begingroup\$ -308 bytes (2.4.1 online only) \$\endgroup\$
    – emanresu A
    Dec 9, 2021 at 9:56
10
\$\begingroup\$

C (Modern Linux), 19 bytes

I suggested this in chat, but nobody took the oppurtunity. :P Credit to MD XF's hilarious answer.

main(){puts('s');;}

Error message, 18 bytes

Segmentation fault
\$\endgroup\$
6
  • 1
    \$\begingroup\$ But the error message has to be smaller than the program itself... \$\endgroup\$
    – Leaky Nun
    Jul 21, 2017 at 20:08
  • \$\begingroup\$ Byte counts were screwed up, my bad. \$\endgroup\$ Jul 21, 2017 at 20:16
  • 9
    \$\begingroup\$ This is a generic message printed by the shell when subprocess terminates with exit code 139. The C program itself produces no error message at all. \$\endgroup\$
    – Dennis
    Jul 21, 2017 at 21:41
  • 7
    \$\begingroup\$ @Dennis Exit code 139 is actually another lie made up by the shell. Unix distinguishes between signal 11 (W_EXITCODE(0, 11) == 11) and exit code 139 (W_EXITCODE(139, 9) == 139 << 8). Shells set $? non-surjectively to WIFEXITED(wstatus) ? WEXITSTATUS(wstatus) : WTERMSIG(wstatus) + 128, but most languages expose the difference. \$\endgroup\$ Jul 22, 2017 at 18:05
  • 4
    \$\begingroup\$ @Anders Is WIFEXITED(wstatus) equivalent to DIVORCE(alimony) by any chance? \$\endgroup\$ Jul 27, 2017 at 10:50
10
\$\begingroup\$

Commodore 64 Basic, 15 bytes

?SYNTAX   ERROR

Produces

?SYNTAX  ERROR

(Note two spaces in the error message, where the program has three)

?SYNTAX ERROR is tied with ?VERIFY ERROR as the third-shortest error message that C64 Basic can produce, and the shortest that can be reliably triggered by code (the shortest message, BREAK IN 1, requires user interaction, while ?LOAD ERROR requires a defective tape or floppy disk, and ?VERIFY ERROR requires the presence of a floppy or tape containing a file that doesn't match the program in RAM).

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Ha, didn't even see this when I posted mine. Always good to see another BASIC user... +1 \$\endgroup\$
    – MD XF
    Jul 23, 2017 at 0:51
9
\$\begingroup\$

PowerShell, 215 189 bytes

[]
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

Try it online!

So, PowerShell has ... verbose ... error messages. Additionally, most non-syntax error messages are Runtime Exceptions, meaning that they're non-fatal, which reduces this problem to needing to find a short parsing error.

I think this is one of the shortest, if not the shortest, @TessellatingHeckler has demonstrated this is the shortest parsing error, and it still weighs in at 188 bytes just for the error message. So we basically need to append enough 1s to reach 189 bytes of "code."

Running this locally on c:\a.ps1 for example, will cut down on the byte count by a handful as it's just a shorter file path, but then it's not available on TIO.

Produces error:

At /tmp/home/.code.tio.ps1:1 char:2
+ []
+  ~
Missing type name after '['.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingTypename
\$\endgroup\$
7
  • \$\begingroup\$ I was asked three questions in the comments, one of which you asked, but the two you didn't ask both applied to your answer, and not yours. \$\endgroup\$
    – user72528
    Jul 21, 2017 at 19:37
  • \$\begingroup\$ @user72528 Yeah, I found that amusing as well. \$\endgroup\$ Jul 21, 2017 at 19:38
  • \$\begingroup\$ You can use a one char file name! \$\endgroup\$
    – Adalynn
    Jul 21, 2017 at 19:54
  • 1
    \$\begingroup\$ @Zacharý I can, but then it's not reproducible on TIO due to how TIO handles the sandboxing. I prefer to keep it usable on TIO than to save a few bytes. \$\endgroup\$ Jul 21, 2017 at 20:00
  • 2
    \$\begingroup\$ What about [] which looks like a shorter error Missing type name after '[' and depending on exactly how you count could be around 190 - tio.run/##K8gvTy0qzkjNyfn/PzqWy3Dogv//AQ (taken from the parser strings here that looks like the shortest parser error to me ([xml](gc .\ParserStrings.resx)).root.data.value | sort { $_.length } -Desc). \$\endgroup\$ Jul 21, 2017 at 21:34
7
\$\begingroup\$

Ruby (33 32 bytes)

32 bytes

&
#abcdefghijklmnopqrstuvwxyz12

Throws the error (assuming in a file named "a"):

31 bytes

a:1: syntax error, unexpected &

Edit: Shaved a byte off by using & instead of << thanks to Eric, who also came up with an even shorter Ruby solution: http://codegolf.stackexchange.com/a/135087/65905

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Welcome to PPCG! \$\endgroup\$ Jul 21, 2017 at 19:56
  • \$\begingroup\$ @EricDuminil nice! I thought all the single character operators were quoted in the error message, but you're right: & isn't. Neat! Also, good find with the hex escape. I was struggling to find a shorter and non-stack-trace fatal error message other than a syntax error. \$\endgroup\$
    – ameketa
    Jul 23, 2017 at 19:53
  • \$\begingroup\$ @ameketa: I actually wrote a bruteforce program and tested every possible 1, 2 and 3-byte Ruby program :D Thanks for the link. \$\endgroup\$ Jul 23, 2017 at 20:50
7
\$\begingroup\$

R, 29 28 bytes

-1 byte thanks to JarkoDubbeldam

a #abcdefghijklmnopqrstuvwxy

Throws the error Error: object 'a' not foundwhich is 27 bytes.

Try it online!

\$\endgroup\$
2
  • 2
    \$\begingroup\$ a #abcdefghijklmnopqrstuvwxy's error Error: object 'a' not found is one byte shorter. \$\endgroup\$
    – JAD
    Jul 23, 2017 at 15:16
  • \$\begingroup\$ @JarkoDubbeldam thank you. \$\endgroup\$
    – Giuseppe
    Jul 25, 2017 at 17:45
5
\$\begingroup\$

Brainf**k, 17 bytes, this interpreter

+++++++++++++++<<

Brainf**k is such a simple language that almost every interpreter has a different error message. This one uses Memory Error: -1 for when the pointer is moved to the left too much and you attempt another operation

\$\endgroup\$
8
  • \$\begingroup\$ I guess choosing an interpreter is as much a part of the challenge as choosing a language. \$\endgroup\$
    – user72528
    Jul 21, 2017 at 19:18
  • \$\begingroup\$ @user72528 Well here, we define a language by its interpreter, so this challenge is a bit about choosing the interpreter with the shortest error messages :) \$\endgroup\$
    – hyper-neutrino
    Jul 21, 2017 at 19:21
  • 1
    \$\begingroup\$ Who beats brainfuck? Nobody? Alright. \$\endgroup\$ Jul 21, 2017 at 19:28
  • \$\begingroup\$ The unbeatable solution would a two byte solution which causes an error of 1 character. \$\endgroup\$
    – Adalynn
    Jul 21, 2017 at 19:30
  • \$\begingroup\$ @Zacharý Certainly lol \$\endgroup\$
    – hyper-neutrino
    Jul 21, 2017 at 19:44
5
\$\begingroup\$

Common Lisp, 20 bytes

(/ 1 0))))))))))))))

Try it online!

Error Message

/: division by zero
\$\endgroup\$
2
  • 12
    \$\begingroup\$ o_o unbalanced parentheses in Lisp ... you learn something new every day. \$\endgroup\$
    – Adalynn
    Jul 21, 2017 at 19:32
  • 1
    \$\begingroup\$ If you replace the 0 with 1, it will error on the parens but it doesn't get that far with 0. I just needed to add characters to be longer than the message \$\endgroup\$
    – Cheldon
    Jul 21, 2017 at 19:34
5
\$\begingroup\$

TryAPL, 11 bytes

Code (11):

'abcdefghij

Error (10):

open quote
\$\endgroup\$
5
\$\begingroup\$

Perl 5, 11 bytes

Since I'm not clear on whether my other answer obeys the challenge rules, here's another alternative.

#line 0
die

Error output:

Died.

With an ending newline, for 6 bytes.

Try it online!

For some reason the Perl interpreter internal function Perl_mess_sv contains:

if (CopLINE(cop))
    Perl_sv_catpvf(aTHX_ sv, " at %s line %" IVdf,
                    OutCopFILE(cop), (IV)CopLINE(cop));

where CopLINE(cop) gets the current code context's line number. So if that line number happens to evaluate to zero, Perl skips adding the usual " at <filename> line <n>" to the error message.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ It seems nor valid to me. IIRC die is for the program to exit. \$\endgroup\$
    – sergiol
    Jul 22, 2017 at 17:34
  • 1
    \$\begingroup\$ How is that any different than python raise? \$\endgroup\$ Jul 23, 2017 at 12:09
  • \$\begingroup\$ Well, the OP might have been referring to either generating the error or the error message. I commented on which one he meant. \$\endgroup\$
    – Adalynn
    Jul 23, 2017 at 14:42
5
\$\begingroup\$

ZX Spectrum Basic, 9 bytes

RUN USR 8

produces:

Error message

Explanation:

I am (exceptionally) counting ASCII representation of the program for length purposes, including the end of line (it's not really important, since we could always pad a shorter program with spaces).

Usually, ZX Spectrum error messages are longer and more helpful than this - the ROM routine at 0x0008 expects error code following the machine code call to RST 8., and fetches some random (deterministic) byte from the ROM, which produces this nonsensical error message M. 5 is the error number, , is added by the error printing routine and 0:1 is the line:command position of the error.

\$\endgroup\$
1
  • \$\begingroup\$ Actually this is 9 bytes normally anyway, because the ZX Spectrum doesn't evaluate numbers at run time, so there are actually 6 hidden bytes which allow it to access the binary representation of 8 directly. \$\endgroup\$
    – Neil
    Jul 23, 2017 at 19:11
5
\$\begingroup\$

ArnoldC, 150 bytes

IT'S SHOWTIME
HEY CHRISTMAS TREE b
YOU SET US UP 0
GET TO THE CHOPPER b
HERE IS MY INVITATION b
HE HAD TO SPLIT 0
ENOUGH TALK
YOU HAVE BEEN TERMINATED

Try it online!

Error is 94 bytes (including trailing newline):

Exception in thread "main" java.lang.ArithmeticException: / by zero
    at code.main(Hello.java)

Preserved because I think this is more funny - spoiler: it was those dang teenage pranksters.

ArnoldC, 280 bytes

IT'S SHOWTIME
HEY CHRISTMAS TREE BRBDoorBetterNotBeThosePeskyTeenagePranksters
YOU SET US UP 0
GET YOUR ASS TO MARS BRBDoorBetterNotBeThosePeskyTeenagePranksters
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
YOU HAVE BEEN TERMINATED

Pseudocode:

start program
new variable
set to 0
set new variable to output from function
call function
take input
end program

Try it online!

Generates a "no input" error. (Almost all other errors in ArnoldC include a large piece of boilerplate):

279 bytes (including trailing newline):

Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Scanner.java:862)
    at java.util.Scanner.next(Scanner.java:1485)
    at java.util.Scanner.nextInt(Scanner.java:2117)
    at java.util.Scanner.nextInt(Scanner.java:2076)
    at code.main(Hello.java)
\$\endgroup\$
4
\$\begingroup\$

Perl 5, 5 bytes

die$/

Outputs a newline, for one byte.

Try it online!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ ._. Now ... if only perl errors on the empty file! \$\endgroup\$
    – Adalynn
    Jul 22, 2017 at 1:34
  • 6
    \$\begingroup\$ Wait, is this a violation of the "may not be generated by the program itself"? I didn't understand what that rule was saying. \$\endgroup\$
    – aschepler
    Jul 22, 2017 at 1:41
  • 1
    \$\begingroup\$ @Zacharý ... giving an error message with total length negative one? \$\endgroup\$
    – aschepler
    Jul 22, 2017 at 1:54
  • 1
    \$\begingroup\$ This might be invalid ... or not, depends on whether the OP meant the error or the error message \$\endgroup\$
    – Adalynn
    Jul 22, 2017 at 2:14
  • \$\begingroup\$ ^ clarification: whether a program errors directly or creates an error message directly \$\endgroup\$
    – Adalynn
    Jul 23, 2017 at 0:31
4
\$\begingroup\$

GW-Basic, 9 bytes

Enter:

?&H100000

This will yield the following error message:

Overflow

I believe this is the shortest error message in GW-Basic. The reason I used a hexadecimal constant is that while GW-Basic doesn't support long integers, it does support single and double(!) precision floating point numbers.

\$\endgroup\$
4
\$\begingroup\$

Whitespace (on TIO), 34 bytes

 
Nope, it's not valid Whitespace!

Try it online.

All characters that aren't a space, tab, or newline are ignore in Whitespace. So this program is actually SNSSS (where S is space, and N is newline). The first three (SNS) is the command to duplicate the value at the top of the stack. Since the stack is still empty, it gives the error:

wspace: user error (Can't do Dup)

I tried other errors, but this seems to be the shortest. Most errors where it tries to use a value on the stack which isn't present are similar, but longer. Here is a list of all possible errors (I could find) on TIO (for the first one it requires a character input, which it tries to read and print as number, so I've excluded that one - Try it online.):

wspace: Prelude.read: no parse
wspace: user error (Can't do Dup)
wspace: user error (Can't do Swap)
wspace: Prelude.!!: index too large
wspace: user error (Can't do Store)
wspace: user error (Can't do Return)
wspace: user error (Can't do Discard)
wspace: user error (Can't do Slide 0)
wspace: user error (Can't do ReadNum)
wspace: user error (Can't do Retrieve)
wspace: user error (Can't do ReadChar)
wspace: <stdin>: hGetChar: end of file
wspace: <stdin>: hGetLine: end of file
wspace: user error (Can't do OutputNum)
wspace: Prelude.chr: bad argument: (-1)
wspace: user error (Can't do Infix Plus)
wspace: user error (Can't do OutputChar)
wspace: user error (Undefined label ( ))
wspace: user error (Can't do Infix Minus)
wspace: user error (Can't do Infix Times)
wspace: user error (Can't do If Zero " ")
wspace: user error (Can't do Infix Divide)
wspace: user error (Can't do Infix Modulo)
wspace: user error (Can't do If Negative " ")
wspace: Input.hs:(108,5)-(109,51): Non-exhaustive patterns in function parseNum'
wspace: Unrecognised input\nCallStack (from HasCallStack):\n  error, called at Input.hs:103:11 in main:Input
wspace: Stack space overflow: current size 33624 bytes.\nwspace: Relink with -rtsopts and use `+RTS -Ksize -RTS' to increase it.

NOTE: Whitespace compilers have their own implementations for error messages. All these errors above are on TIO. If I use the online Whitespace compiler vii5ard instead, and use the same program at the top, it will give this error instead:

ERROR: Runtime Error: Stack underflow

So using the vii5ard online Whitespace compiler I could lower my byte-score to:

Whitespace (on vii5ard), 15 bytes

Unexpected EOF!

Which is the 'program' S (a single space), resulting in the error:

Unexpected EOF

(Which would result in wspace: Unrecognised input\nCallStack (from HasCallStack):\n error, called at Input.hs:103:11 in main:Input on TIO).

\$\endgroup\$
4
\$\begingroup\$

05AB1E, 410 411 bytes

One plus one is two, two plus two is four.
And now, some random character spam just because I can.
3...
2...
1...
GO!

ooi1u4`o1i2)I#1n[09i43u`1@#~!@#{10239`]ι@(~!)2ioausioe7u12o3iu71p3123`71i2`8127l5ruy;3948'p3298rv9pe8huep'r8i19o`8u'3pie8uiouI!^23uT7T17I3YJH~:L'I`YU2O123;121@

That should be about it, it errored. Guess that's what happens when you spam. Bye for now!


upvote if you liked my creativity


:)

Try it online!

One plus one i...]ι...  # trimmed program
One plus one            # push empty string ("") twice
             i          # if top of stack is truthy...
              ...       # execute (trimmed) code (this is unreachable)
                 ]      # exit all opened statements
                  ι     # not exactly sure what this function does, but part of it forcefully converts top of stack to an integer (without error handling), therefore erroring
                   ...  # unreachable code as program has quit from the fatal error

Error, 410 bytes

** (RuntimeError) Could not convert  to integer.
    (osabie) lib/interp/functions.ex:101: Interp.Functions.to_integer!/1
    (osabie) lib/interp/commands/special_interp.ex:113: Interp.SpecialInterp.interp_step/3
    (osabie) lib/interp/interpreter.ex:127: Interp.Interpretr.interp/3
    (osabie) lib/osabie.ex:62: Osabie.CLI.main/1
    (elixir) lib/kernel/cli.ex:105: anonymous fn/3 in Kernel.CLI.exec_fun/2

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

Javascript (Firefox), 29 27 bytes

new Date('-').toISOString()

throws RangeError: invalid date which is 24 bytes. Tested on Firefox 54.0.1 on Windows 10.

\$\endgroup\$
1
2 3 4 5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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