Outputs to STDERR
Outputting to STDERR is now at +33/-21 as an allowed default, which is positive but contested. This is a CW answer to collect answers that just invoke an error in a language where error messages includes the language name.
1
Error:
Parse error: naked expression at top level
Perhaps you intended to use TemplateHaskell
1
Error:
lua: .code.tio:1: syntax error near <eof>
(file name is unimportant)
Batch, 1 byte
~
Error:
'~' is not recognized as an internal or external command,
operable program or batch file.
(c()1
Error:
Error: cannot cons to Int in tinylisp
R, 1 byte
)
Error:
Error: unexpected ')' in ")"
Java bytecode, 0 bytes
Error:
Exception in thread "main" java.lang.ClassFormatError: Truncated class file
Groovy, 1 byte
a
Note that a
can be replaced with any other character
Error:
groovy.lang.MissingPropertyException: No such property: a ...
MATLAB, 1 byte
\
Error:
Error: Unexpected MATLAB operator.
<?=
Error:
PHP Parse error: syntax error, unexpected end of file in /home/runner/.code.tio on line 1
CJam, 1 byte
/
Error:
/
^
RuntimeException: The stack is empty
Java exception:
java.lang.RuntimeException: The stack is empty
at net.aditsu.cjam.CJam.pop(CJam.java:75)
at net.aditsu.cjam.Op2.run(Op2.java:10)
at net.aditsu.cjam.Block.run(Block.java:304)
at net.aditsu.cjam.CJam.runCode(CJam.java:210)
at net.aditsu.cjam.CJam.main(CJam.java:240)
Twig is a template language written in PHP. It's possible that this is a polyglot.
{{
{%
{#
Error:
PHP Fatal error: Uncaught exception 'Twig_Error_Syntax' with message [...] in [...][...]:n:
Stack trace:
#0 [...]
The message varies depending on which program you choose.
x+
Try it online!
Trivially invokes undocumented behavior. Silos is the name of the language.
Python, 6 bytes
pYTHON
As the character restriction is case insensitive, and the output doesn't have to be in the correct case, this is a valid answer. The error message it produces is something like this:
Traceback (most recent call last):
File ".code.tio", line 1, in <module>
pYTHON
NameError: name 'pYTHON' is not defined
Try it online! (outputs to 'debug' tab)
JavaScript, 10 bytes
jAVAsCRIPT
This produces the following error message or similar in all environments:
ReferenceError: jAVAsCRIPT is not defined
QBIC, 6 bytes
?b(12)
In 6 bytes, we can put QBIC encountered error: 9 on the screen, signifying an out-of-bounds error.
ForceLang, 2 bytes
()
Error produced:
Exception in thread "main" lang.exceptions.IllegalInvocationException: null is not a function.
at lang.ForceLang.parse(ForceLang.java:99)
at lang.ForceLang.main(ForceLang.java:129)
1~`[`
(Note: this works in the current version as of this writing, 0.17.09.01. No guarantees the interpreter won't change to handle this error differently in the future.)
Tries to regex match with a syntactically invalid pattern. The error produced will look something like this:
Traceback (most recent call last):
File "/opt/pip/pip.py", line 221, in <module>
pip(interactive=False)
File "/opt/pip/pip.py", line 206, in pip
state.executeProgram(tree, args)
File "/opt/pip/execution.py", line 56, in executeProgram
returnVal = self.functionCall(mainFunction, cmdLineArgs)
File "/opt/pip/execution.py", line 368, in functionCall
returnVal = self.getRval(returnExpr)
File "/opt/pip/execution.py", line 235, in getRval
expr = self.evaluate(expr)
File "/opt/pip/execution.py", line 213, in evaluate
result = opFunction(*args)
File "/opt/pip/execution.py", line 1134, in FIRSTMATCH
matchObj = regex.asRegex().search(str(string))
File "/opt/pip/ptypes.py", line 175, in asRegex
self._compiled = re.compile(pyRegex)
File "/usr/lib64/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/usr/lib64/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib64/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/usr/lib64/python3.6/sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "/usr/lib64/python3.6/sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "/usr/lib64/python3.6/sre_parse.py", line 765, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "/usr/lib64/python3.6/sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "/usr/lib64/python3.6/sre_parse.py", line 523, in _parse
source.tell() - here)
sre_constants.error: unterminated character set at position 8
0u
Error:
Stax runtime error: rational divide by zero
zh
also works.
~
~
at the start of a line marks that the line is a statement to be executed, rather than text to be printed. As of whichever version of inklecate TIO is using, if there's nothing after the ~
, the interpreter crashes with the following error:
System.NullReferenceException: Object reference not set to an instance of an object
at Ink.InkParser.LogicLine () [0x000b1] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.StringParser.ParseObject (Ink.StringParser+ParseRule rule) [0x00012] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.StringParser.OneOf (Ink.StringParser+ParseRule[] array) [0x0000a] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.InkParser.StatementAtLevel (Ink.InkParser+StatementLevel level) [0x00009] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.InkParser+<>c__DisplayClass134_0.<StatementsAtLevel>b__0 () [0x00000] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.StringParser.ParseObject (Ink.StringParser+ParseRule rule) [0x00012] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.StringParser.Interleave[T] (Ink.StringParser+ParseRule ruleA, Ink.StringParser+ParseRule ruleB, Ink.StringParser+ParseRule untilTerminator, System.Boolean flatten) [0x00040] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.InkParser.StatementsAtLevel (Ink.InkParser+StatementLevel level) [0x0004f] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.InkParser.Parse () [0x00000] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.Compiler.Compile () [0x00033] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.CommandLineTool..ctor (System.String[] args) [0x001a3] in <d64e27e7788347b2a5377c9e19bbdcab>:0
at Ink.CommandLineTool.Main (System.String[] args) [0x00000] in <d64e27e7788347b2a5377c9e19bbdcab>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at Ink.InkParser.LogicLine () [0x000b1] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.StringParser.ParseObject (Ink.StringParser+ParseRule rule) [0x00012] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.StringParser.OneOf (Ink.StringParser+ParseRule[] array) [0x0000a] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.InkParser.StatementAtLevel (Ink.InkParser+StatementLevel level) [0x00009] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.InkParser+<>c__DisplayClass134_0.<StatementsAtLevel>b__0 () [0x00000] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.StringParser.ParseObject (Ink.StringParser+ParseRule rule) [0x00012] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.StringParser.Interleave[T] (Ink.StringParser+ParseRule ruleA, Ink.StringParser+ParseRule ruleB, Ink.StringParser+ParseRule untilTerminator, System.Boolean flatten) [0x00040] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.InkParser.StatementsAtLevel (Ink.InkParser+StatementLevel level) [0x0004f] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.InkParser.Parse () [0x00000] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.Compiler.Compile () [0x00033] in <b1e5e74f4ee842fc961297862cf23e07>:0
at Ink.CommandLineTool..ctor (System.String[] args) [0x001a3] in <d64e27e7788347b2a5377c9e19bbdcab>:0
at Ink.CommandLineTool.Main (System.String[] args) [0x00000] in <d64e27e7788347b2a5377c9e19bbdcab>:0
7The rule about case sensitive restrictions is very ambiguous. Which is the correct orthography: BASIC Basic or basic? I'm pretty sure I can find examples for all three. – Level River St – 2017-01-24T23:47:47.737
7Obligatory "Just having your code be blank but have a flag like
--version
isn't allowed"? – Value Ink – 2017-01-25T00:00:54.73388Have case-insensitive output while banning the language name case-sensitively allows boring solutions that just output the language name case-swapped. – xnor – 2017-01-25T00:47:59.327
2Does the output need to go to the screen/be printed, or can it be returned as well? – simbabque – 2017-01-25T13:48:41.507
1@xnor Agreed. This should be changed. – mbomb007 – 2017-01-25T14:53:02.830
1@xnor I won't change it, because outputting the name case-swapped would need at least the amount of bytes the name is, which allows more creative answers to win, since they would have lower byte count. – P. Ktinos – 2017-01-25T15:08:51.490
Can I pass my language name as a command line argument if my language does not have a method to reliably print what's passed, and may even automatically error on certain command line arguments? The idea is that the command line argument specifies the regex that is used to parse the source code. My language name happens to be valid regex, and would lead to a (semi-) interesting solution. Because of certain constraints, it may not even be optimal, as command line arguments add to your byte count. – MildlyMilquetoast – 2017-01-25T17:20:28.597
12You made a mistake by allowing users to output junk data. All they have to do is use a language where the compiler include the name whenever there's an error. It's cool but not the challenge I was hoping for – Lynob – 2017-01-26T08:23:26.603
Can the filename of the program include the language name? – leancz – 2017-01-26T11:59:36.710
3This question really needs to be specified that "Code" must be run. Most languages will show their name in the usage dump if you don't give any code--for instance "Java" or "Groovy" at the command line with no code will display the correct name, however if you pass code (even "empty" code) as in (groovy -e "") you will get an empty response. Same for compile problems, the compiler usage or error output does not mean you wrote a program. – Bill K – 2017-01-26T18:30:31.123
1@Lynob to be honest, if we wanted something creative we would need to ban ascii code/unicode/and such things. – Walfrat – 2017-01-27T12:08:10.877
@Lynob preventing output to stderr should prevent a lot of language to use such a trick – Sefa – 2017-01-27T13:32:16.697
Unfortunately I can't do it in Smalltalk.
Object comment
uses 2 characters in the name Smalltalk. – None – 2019-08-27T15:11:13.247