wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
function bar() {{ echo 'hello'; }}
function bar() {{ echo 'hello'; }}
Correct.
PHP
67count = 10
count67 = 10
Variable cannot start with digit.
Python
os.sqrt(73)
import os os.sqrt(73)
Import module first.
Python
<img src='info.jpg'>
<img src='info.jpg' alt='desc'>
Add alt text.
HTML
<a href='https://test.org' target='_blank'>
<a href='https://test.org' target='_blank' rel='noopener'>
Add rel for security.
HTML
let num: i32 = "output";
let num: &str = "output";
Type mismatch.
Rust
echo 'hello'
echo 'hello';
Add semicolon.
PHP
int list[2]; list[2]=5;
int list[2]; if(2<2){{}} else list[2]=5;
Bounds check.
C++
if y > 44 puts 'value'
if y > 44 puts 'value' end
Add 'end'.
Ruby
x := 85
x := 85
Correct.
Go
var x int
var x int
Correct.
Go
const count = 24; count = 76;
let count = 24; count = 76;
Cannot reassign const.
JavaScript
local index = 50
local index = 50
Correct.
Lua
String c = 'output';
String c = "output";
Double quotes.
Java
<person age=74>
<person age="74">
Quote attribute.
XML
for i=1,12 do print(i) end
for i=1,12 do print(i) end
Correct.
Lua
let c: number | null = null; c.toFixed(66);
let c: number | null = null; if(c!==null) c.toFixed(66);
Null check.
TypeScript
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
class = 'message'
class_name = 'message'
'class' is a keyword.
Python
int[] arr = new int[13]; arr[13] = 5;
int[] arr = new int[13]; if (13 < arr.length) arr[13] = 5;
Check bounds.
Java
if (y = 39)
if (y == 39)
Use ==.
R
my @arr = (52,97,92);
my @arr = (52,97,92);
Correct.
Perl
<center>result</center>
<div style='text-align:center;'>result</div>
Use CSS.
HTML
<entry><desc>data</desc><desc>85</desc></entry
<entry><desc>data</desc><desc>85</desc></entry>
Add closing >.
XML
SELECT * FROM items WHRE name=93;
SELECT * FROM items WHERE name=93;
Fix WHERE.
SQL
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(47);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(47, () => console.log('listening'));
Add callback.
Node.js
a = test
a = 'test'
Quote strings.
Python
<a href='https://test.org' target='_blank'>
<a href='https://test.org' target='_blank' rel='noopener'>
Add rel for security.
HTML
function foo() {{ return {{key:'hello'}} }}
function foo() {{ return {{key:'hello'}}; }}
Return object on same line.
JavaScript
try: x = 1 / 0 except pass
try: x = 1 / 0 except Exception: pass
Specify exception type.
Python
values(91)
if length(values) >= 91, values(91), end
Check length.
MATLAB
System.out.println('result')
System.out.println('result');
Add semicolon.
Java
if (data) console.log('yes') else console.log('no')
if (data) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
fmt.Println 'info'
fmt.Println('info')
Missing parentheses.
Go
count = 90
count=90
No spaces.
Shell
echo 'output'
echo 'output';
Add semicolon.
PHP
DELETE FROM orders WHERE email=48
DELETE FROM orders WHERE email=48;
Add semicolon.
SQL
'value' + 20
'value' + str(20)
Can't add int to string.
Python
<img src='data.jpg'>
<img src='data.jpg' alt='desc'>
Add alt text.
HTML
["value", 87]
["value", 87]
Correct.
JSON
jwt.sign({{id:77}}, 'token');
jwt.sign({{id:77}}, 'token', {{expiresIn:'7d'}});
Add expiration.
Node.js
{{"value":"test" "age":19}}
{{"value":"test", "age":19}}
Add comma.
JSON
80temp = 10
temp80 = 10
Variable cannot start with digit.
Python
<input type='text' value='hello'>
<input type='text' value='hello' name='age'>
Add name attribute.
HTML
$result = 71; if ($result = 71) {{}}
$result = 71; if ($result == 71) {{}}
Use ==.
PHP
if a = 20
if a == 20
Use ==.
MATLAB
@media screen {{ body {{}} }}
@media screen {{ body {{}} }}
Correct.
CSS
cin >> item cout << item;
cin >> item; cout << item;
Add semicolon.
C++
Order.save();
Order.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
class Order {{ int temp; }} obj.temp=5;
class Order {{ public int temp; }} obj.temp=5;
Make field public.
Java
val c = 'hello'
val c = "hello"
Double quotes.
Kotlin
'info' + 87
'info' + 87.to_s
Convert int.
Ruby
handle
handle()
Add parentheses.
Kotlin
String a = 'data';
String a = "data";
Double quotes.
Java
if z = 2
if z == 2
Use ==.
Go
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
#header {{ color: green; }}
#header {{ color: green; }}
Correct.
CSS
if (count = 53) {}
if (count == 53) {}
Use ==.
Dart
$x = 5; echo $x
$x = 5; echo $x;
Missing semicolon.
PHP
const z;
const z = 97;
Initialize const.
JavaScript
<entry name='output'/>
<entry name="output"/>
Double quotes.
XML
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(88);
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(88);
Correct.
Node.js
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
disp('data')
disp('data')
Correct.
MATLAB
for i=1,54 do print(i) end
for i=1,54 do print(i) end
Correct.
Lua
print 'hello'
print('hello')
Parentheses for function call.
Lua
render
render()
Add parentheses.
Swift
SELECT COUNT(*) FROM items
SELECT COUNT(*) FROM items;
Missing semicolon.
SQL
let index: number = 'result';
let index: string = 'result';
Fix type.
TypeScript
<person age=70>
<person age="70">
Quote attribute.
XML
def bar(item): return item + 1
def bar(item): return item + 1
Correct.
Python
var x = 5; x = true
var x = 5; x = 10
Type mismatch.
Kotlin
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
Correct.
PowerShell
[61, 93, 56
[61, 93, 56]
Close bracket.
Python
name: test age: hello,
name: test age: hello
Remove comma.
YAML
if num > 39 print('value')
if num > 39: print('value')
Colon missing after if.
Python
list[28]
if list.indices.contains(28) {{ list[28] }}
Check index.
Swift
<hr></hr>
<hr>
Self-closing.
HTML
def test(): print('world')
def test(): print('world')
Indent function body.
Python
if num = 81:
if num == 81:
Use == for comparison.
Python
<div color=#333>
<div style='color:#333;'>
Use style attribute.
CSS
local val = 62
local val = 62
Correct.
Lua
$values[41] = 5;
if (isset($values[41])) $values[41] = 5;
Check existence.
PHP
<div><p>value</div></p>
<div><p>value</p></div>
Nest properly.
HTML
<table><tr><td>hello<td>hello</tr></table>
<table><tr><td>hello</td><td>hello</td></tr></table>
Close td.
HTML
object Person {{ def main(args: Array[String]) = println("info") }}
object Person {{ def main(args: Array[String]): Unit = println("info") }}
Add return type Unit.
Scala
String name = 'result';
String name = 'result';
Correct.
Dart
{{'age':'result'}}
{{"age":"result"}}
Use double quotes.
JSON
for (int i=0; i<75; i++) {{}}
for (int i=0; i<75; i++) {{}}
Correct.
Java
if ($count = 34) {{}}
if ($count -eq 34) {{}}
Use -eq.
PowerShell
SELECT age status FROM orders;
SELECT age, status FROM orders;
Add comma.
SQL
class Child Super:
class Child(Super):
Inheritance uses parentheses.
Python
x := 68
x := 68
Correct.
Go
[4, 47, 44
[4, 47, 44]
Close bracket.
Ruby
if foo = 62
if foo == 62
Use ==.
Ruby
for i in $(ls); do echo $i; done
for i in $(ls); do echo $i; done
Correct.
Shell
var x int
var x int
Correct.
Go
function bar(b:string){{return b;}} bar(86);
function bar(b:string){{return b;}} bar('world');
Pass correct type.
TypeScript
if [ $y = 88 ]; then
if [ "$y" = 88 ]; then
Quote variable.
Shell