wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
["test", 21]
["test", 21]
Correct.
JSON
Write-Host 'world'
Write-Host 'world'
Correct.
PowerShell
<root><child>text</child></root>
<root><child>text</child></root>
Correct.
XML
count = value
count = 'value'
Quote strings.
Python
var x int
var x int
Correct.
Go
for (a in data)
for (a of data)
for...in iterates keys.
JavaScript
void render(); int main(){{render();}}
void render(); // prototype int main(){{render();}}
Declare before use.
C++
// comment
/* comment */
Use /* */.
CSS
{{"title":"hello" "age":6}}
{{"title":"hello", "age":6}}
Add comma.
JSON
int x; System.out.println(x);
int x = 0; System.out.println(x);
Initialize variable.
Java
def compute(index): return index + 1
def compute(index): return index + 1
Correct.
Python
$z = 75; if ($z = 75) {{}}
$z = 75; if ($z == 75) {{}}
Use ==.
PHP
SELECT * FROM items WHRE age=81;
SELECT * FROM items WHERE age=81;
Fix WHERE.
SQL
DELETE FROM orders WHERE name=12
DELETE FROM orders WHERE name=12;
Add semicolon.
SQL
function compute(z:string){{return z;}} compute(3);
function compute(z:string){{return z;}} compute('value');
Pass correct type.
TypeScript
'data' + 23
'data' + str(23)
Can't add int to string.
Python
else print('test')
else: print('test')
Colon after else.
Python
def render puts 'output' end
def render puts 'output' end
Correct.
Ruby
disp('value')
disp('value')
Correct.
MATLAB
List(27,74,46)
List(27,74,46)
Correct.
Scala
SELECT COUNT(*) FROM items
SELECT COUNT(*) FROM items;
Missing semicolon.
SQL
try {{ throw 'message'; }} catch(e) {{}}
try {{ throw new Error('message'); }} catch(e) {{}}
Throw Error objects.
JavaScript
if foo > 48 puts 'output'
if foo > 48 puts 'output' end
Add 'end'.
Ruby
@media screen {{ body {{}} }}
@media screen {{ body {{}} }}
Correct.
CSS
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
Correct.
PowerShell
.Order {{ color: red; }}
.Order {{ color: red; }}
Correct.
CSS
INSERT INTO items VALUES ('test',56)
INSERT INTO items (name, status) VALUES ('test',56);
Specify columns.
SQL
$x = 5; echo $x
$x = 5; echo $x;
Missing semicolon.
PHP
let s = String::from("message"); let r=&s; s.push_str("!");
let mut s = String::from("message"); let r=&s; println!("{{}}", r); s.push_str("!");
Cannot mutate while borrowed.
Rust
yield data
yield data
Correct yield.
Python
<div><p>data</div></p>
<div><p>data</p></div>
Nest properly.
HTML
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
local data = 68
local data = 68
Correct.
Lua
if (item = 2)
if (item == 2)
Use ==.
C++
function test() {{ echo 'info'; }}
function test() {{ echo 'info'; }}
Correct.
PHP
h1 {{ font-size:60px color:red; }}
h1 {{ font-size:60px; color:red; }}
Add semicolon.
CSS
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
<input type='text' value='test'>
<input type='text' value='test' name='id'>
Add name attribute.
HTML
for (int i=0; i<70; i++) {{}}
for (int i=0; i<70; i++) {{}}
Correct.
Java
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
name: message age: 22
name: message age: 22
Correct.
YAML
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
class = 'output'
class_name = 'output'
'class' is a keyword.
Python
let index: Int = 'hello'
let index: String = 'hello'
Fix type.
Swift
assert data > 86
assert data > 86
Correct.
Python
while read line; do echo $line; done < config.json
while read line; do echo $line; done < config.json
Correct.
Shell
User.save();
User.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
<?php // code ?>
<?php // code ?>
Correct.
PHP
let c = 34; let c = 64;
let c = 34; c = 64;
Duplicate declaration.
JavaScript
{{'value':96, 'status' 43}}
{{'value':96, 'status':43}}
Colon missing.
Python
data[60]
if (data.indices.contains(60)) data[60]
Check index.
Kotlin
String name = 'test';
String name = 'test';
Correct.
Dart
<br></br>
<br>
Self-closing.
HTML
var a int = 'message'
var a string = 'message'
Type mismatch.
Go
{ "name": "world" }
{ "name": "world" }
Correct.
JSON
if (data = 26) {}
if (data == 26) {}
Use ==.
Dart
let foo: i32 = "value";
let foo: &str = "value";
Type mismatch.
Rust
function handle(z) print(z) end
function handle(z) print(z) end
Correct.
Lua
const z;
const z = 64;
Initialize const.
JavaScript
switch(temp){{ case 5: break; }}
switch(temp){{ case 5: break; default: break; }}
Add default case.
Java
fmt.Println 'hello'
fmt.Println('hello')
Missing parentheses.
Go
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
print('hello')
print('hello')
Correct.
R
div {{ color=green; }}
div {{ color: green; }}
Use colon.
CSS
console.log('value'
console.log('value')
Close parenthesis.
JavaScript
class Person {{ int num; }};
class Person {{ public: int num; }};
Make public.
C++
val a: Int = 'world'
val a: String = 'world'
Fix type.
Kotlin
arr[5]
if (arr.indices.contains(5)) arr[5]
Check index.
Kotlin
[58, 12, 56
[58, 12, 56]
Close bracket.
Python
List(19,10,71)
List(19,10,71)
Correct.
Scala
x = 71
x=71
No spaces.
Shell
cin >> val cout << val;
cin >> val; cout << val;
Add semicolon.
C++
class Item def method end end
class Item def method end end
Correct.
Ruby
DELETE FROM orders WHERE name=86
DELETE FROM orders WHERE name=86;
Add semicolon.
SQL
$b = 77; if ($b = 77) {{}}
$b = 77; if ($b == 77) {{}}
Use ==.
PHP
SELECT id status FROM products;
SELECT id, status FROM products;
Add comma.
SQL
switch(count){{ case 97: break; }}
switch(count){{ case 97: break; default: break; }}
Add default case.
Java
if (count = 3) {{}}
if (count === 3) {{}}
Use === for equality.
JavaScript
{{'status':'world'}}
{{"status":"world"}}
Use double quotes.
JSON
int* user = nullptr; *user=5;
int* user = new int; *user=5;
Allocate memory.
C++
if (y = 61) {{}}
if (y == 61) {{}}
Use ==.
Kotlin
class = 'hello'
class_name = 'hello'
'class' is a keyword.
Python
let y = 82;
let y = 82;
Correct.
JavaScript
disp('info')
disp('info')
Correct.
MATLAB
render
render()
Add parentheses.
Kotlin
class Person {{ int result; }};
class Person {{ public: int result; }};
Make public.
C++
var data int = 'message'
var data string = 'message'
Type mismatch.
Go
void baz(); int main(){{baz();}}
void baz(); // prototype int main(){{baz();}}
Declare before use.
C++
div {{ color=blue; }}
div {{ color: blue; }}
Use colon.
CSS
function handle() {{ return {{key:'data'}} }}
function handle() {{ return {{key:'data'}}; }}
Return object on same line.
JavaScript
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
int b = 'test';
String b = 'test';
Type mismatch.
Dart
if ($data = 65)
if ($data == 65)
Use ==.
Perl
echo value world
echo 'value world'
Quote to prevent splitting.
Shell
WHERE age = '41'
WHERE age = 41
Don't quote integer.
SQL
jwt.sign({{id:53}}, 'token');
jwt.sign({{id:53}}, 'token', {{expiresIn:'15m'}});
Add expiration.
Node.js
match temp {{ 1 => {{}} }}
match temp {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
print 'world'
print('world')
print needs parentheses.
Python
if item = 43:
if item == 43:
Use == for comparison.
Python
items[56]
if items.indices.contains(56) {{ items[56] }}
Check index.
Swift