# Fake error message

Write a program that prints out the syntax error message of the compiler or interpreter. The error message should be misleading so that code maintainers will take days to find out that the error was faked, that means, you should obfuscate (and hide your intention). Also, the error must be as exact as possible, and should reference to the code correctly.

For complied languages, assume your code maintainer will do compile program.p && ./program on the command line to compile AND run the program, that means, he cannot distinguish if the output comes from the compiler or the program itself. Also, assume your code maintainer will turn on syntax error messages.

For reference, here is an example I made: https://gist.github.com/359604

The DATA section encodes the string of error message, and the hash %abcdef is the decode table. The error printed references to the backslashes, which makes a code maintainer will try to count the backslashes.

• Code has an deceptively obvious intention /6
• Code reproduces error correctly /16 (your point starts with 16, and divide by the corresponding factors for each inaccuracies)
• Correct capitalization: 4
• Correct line number and column number: 4
• Correct wording: 2 for each incorrect words
• The line number referenced misleads the code maintainer /3

For example,

./pythontest1.py: line 7: syntax error near token ('
./pythontest1.py: line 7:    x=input("Enter a number:") #Number input'


gets 8 (16 / 2) on correctness for missing "unexpected" before "token", a normal Python interpreter displays

./pythontest1.py: line 7: syntax error near unexpected token ('
./pythontest1.py: line 7:    x=input("Enter a number:") #Number input'


If your "code reproduces error correctly" point is under 1, your entry disqualifies.

In case of a tie, I will put up additional grading factors.

## Python

import sys,traceback
try:
f=open(sys.argv[0])
except Exception, e:
traceback.print_exc(0)


This is a program that should take a filename on the command line, evaluate the first line in it, and print the result. It has 2 bugs. The major bug is that it should use sys.argv[1], not sys.argv[0], so it ends up evaluating the program itself, not the contents of the file named by the first argument. The second bug is that the argument to print_exc makes it print only the deepest frame on the stack, hiding the fact that the error took place inside the eval. As a result, you get an error like this:

$python fake_error.py twelve Traceback (most recent call last): File "<string>", line 1 import sys,traceback ^ SyntaxError: invalid syntax  This looks very much like the first line of the program has a syntax error. It's not quite right as the file is <string>, not fake_error.py, but otherwise it is indistinguishable from the case where, for example, you spell import wrong. Both errors are somewhat "underhanded" in that they could be accidental. • This is brilliant – Cruncher Dec 13 '13 at 15:59 • Brilliant. This reminds me of another oddity of Python. Running raise in Python 2, but in IDLE, python's default IDE, causes an internal error printing gibberish about queues. Traceback (most recent call last): ** IDLE Internal Exception: File "2.7/lib/python2.7/idlelib/run.py", line 325, in runcode exec code in self.locals File "2.7/lib/python2.7/idlelib/run.py", line 111, in main seq, request = rpc.request_queue.get(block=True, timeout=0.05) File "2.7/lib/python2.7/Queue.py", line 176, in get raise Empty – The Matt Jul 9 '18 at 0:50 Reminds me a practical joke. $ ls -l
$cat readme.txt cat: readme.txt: No such file or directory$ echo 'cat: readme.txt: No such file or directory' >readme.txt
$ls -l total 8 -rw-r--r-- 1 florian staff 43 Mar 16 09:52 readme.txt$ cat readme.txt
cat: readme.txt: No such file or directory
\$


## BrainF***

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++[<+++++++++++<++++++++++<++++++++++<+++++++++++<+++++++++++<+++<+++++++++<+++<++++++++++<+++++++++++<++++++++++<+++++++++++<++++++++++<+++++++++++<+++++++++++<+++<+++++++++++<+++++++++<+++<++++++++++<+++++++++++<+++++++++++<++++++++++<++++++++++<+++++++++<+++<++++++++++<++++++++++<+++++++++++<+++++++++<++++++++++<+++++++++++<+++++++++++<+++++++++<+++<+++++++++++<++++++++++<++++++++++<+++++++++++<+++++++++++<+++<+++++++++<+++<++++++++++<+++++++++++<++++++++++<+++++++++++<+++++++++++<++++++++++<+++++++++<+++<+++++<+++++++++++<+++++++++++<+++++++++++<+++++++++++<++++++++++<+++<++++++++++++<+++++++++<+++++++++++<+++++++++++<++++++++++++<++++++++<+++<+++<++++<++++<++++<+++++++>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.>++.>++.>++.>+++.>++.>+++.>+.>.>++++++.>+++++++.>.>++.>+.>++++.>++++.>+.>++++.>++++++++.>++.>+++++++++.>++++++++.>+.>+++++.>+++++.>.>+++.>++.>+++.>++.>++++++.>+.>+++++++.>+.>.>++.>+++++++.>++.>++.>+.>+++++++.>++++.>+.>.>++.>++++++++.>+.>++.>+.>++++.>+.>++.>+++++++.>.>++.>+.>++.>+.>.>+++++.>.>+++.>++.>+.>++.>++++++.>+.>+++++++.>+.>.>


I can't find the particular compiler I used before, but I assure you that that is the exact error message.

• For those of you without BF compilers who are curious, this prints, "F***! Syntax error: closing ] token appeared before an opening [ token" – Peter Olson Apr 28 '11 at 1:38
• It's nice to see you on CG, Minitech :) – Bojangles Jul 7 '13 at 7:40
• Lol, revision history is amusing :P – Doorknob Aug 17 '13 at 2:06

Java

throw new Error();


I didn't know if you meant actually throwing an unhandled exception (as in that example), or simulating an error message. If that is the case, this should work:

C

printf("FATAL ERROR #0xBAD\nProgram execution stopped\n\nIn line 123, character 321, of file 'buggy.c'");


(this assumes that stdio.h is #included)

• oops, just read your post in-depth about the obfuscation part. i would add an obfuscator to it, but i currently don't have access to any ides. [ :( ] when i get one, i will definetly post an obfuscated version (who knows, maybe in even another lang ;) – Nate Koppenhaver Apr 27 '11 at 18:16

## Game Maker Language

show_error("Error: Undefined variable a##Line 1, character 4, of event Create in obj_controller",0)


# ACTIONSCRIPT 3

trace("TypeError: Error #1009: Cannot access a property or method of a null object reference.");