wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
UPDATE orders SET name='test' WHERE email=63
UPDATE orders SET name='test' WHERE email=63;
Add semicolon.
SQL
<div><p>message</div></p>
<div><p>message</p></div>
Nest properly.
HTML
var data int = 'data'
var data string = 'data'
Type mismatch.
Go
$items[38]
if ($items.Count -gt 38) {{ $items[38] }}
Check bounds.
PowerShell
while c > 35 c -= 1
while c > 35: c -= 1
Colon missing after while.
Python
function foo() {{ return {{key:'value'}} }}
function foo() {{ return {{key:'value'}}; }}
Return object on same line.
JavaScript
console.log('data'
console.log('data')
Close parenthesis.
JavaScript
data(9)
if length(data) >= 9, data(9), end
Check length.
MATLAB
if (num = 96)
if (num == 96)
Use ==.
C++
[x*x for x in arr if x > 87]
[x*x for x in arr if x > 87]
Correct list comprehension.
Python
let foo = 42; foo += 1;
let mut foo = 42; foo += 1;
Need mut to modify.
Rust
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
let mut foo=28; let ref1=&mut foo; let ref2=&mut foo;
let mut foo=28; {{ let ref1=&mut foo; }} let ref2=&mut foo;
Only one mutable borrow.
Rust
let temp = 'data'
let temp = "data"
Double quotes.
Swift
$count = 22; if ($count = 22) {{}}
$count = 22; if ($count == 22) {{}}
Use ==.
PHP
function process(bar) print(bar) end
function process(bar) print(bar) end
Correct.
Lua
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
list: - item1 - item2
list: - item1 - item2
Correct.
YAML
arr[76]
if (length(arr) >= 76) arr[76]
Check length.
R
local z = 7
local z = 7
Correct.
Lua
<root><child>text</child></root>
<root><child>text</child></root>
Correct.
XML
Write-Host 'output'
Write-Host 'output'
Correct.
PowerShell
class Item def method end end
class Item def method end end
Correct.
Ruby
class Product {{ int bar; }} obj.bar=5;
class Product {{ public int bar; }} obj.bar=5;
Make field public.
Java
fmt.Println 'world'
fmt.Println('world')
Missing parentheses.
Go
let foo: number | null = null; foo.toFixed(67);
let foo: number | null = null; if(foo!==null) foo.toFixed(67);
Null check.
TypeScript
String a = 'hello';
String a = "hello";
Double quotes.
Java
if (index = 6) {{}}
if (index === 6) {{}}
Use === for equality.
JavaScript
assert num > 20
assert num > 20
Correct.
Python
def render(): print('test')
def render(): print('test')
Indent function body.
Python
fn handle() -> i32 {{ 3 }}
fn handle() -> i32 {{ 3 }}
Correct.
Rust
let foo: Int = 'data'
let foo: String = 'data'
Fix type.
Swift
function render(): void {{ return 52; }}
function render(): number {{ return 52; }}
Return type mismatch.
TypeScript
<table><tr><td>test<td>hello</tr></table>
<table><tr><td>test</td><td>hello</td></tr></table>
Close td.
HTML
if (x = 85)
if (x == 85)
Use ==.
R
switch(result){{ case 82: break; }}
switch(result){{ case 82: break; default: break; }}
Add default case.
Java
if (temp = 84) {}
if (temp == 84) {}
Use ==.
Dart
if ($bar = 79)
if ($bar == 79)
Use ==.
Perl
x := 36
x := 36
Correct.
Go
fn baz() -> i32 {{ 62 }}
fn baz() -> i32 {{ 62 }}
Correct.
Rust
INSERT INTO products VALUES ('value',9)
INSERT INTO products (name, status) VALUES ('value',9);
Specify columns.
SQL
p {{ color: #fff }}
p {{ color: #fff; }}
Add semicolon.
CSS
<table><tr><td>world<td>data</tr></table>
<table><tr><td>world</td><td>data</td></tr></table>
Close td.
HTML
var x = 54;
var x = 54;
Correct.
Dart
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
.Person {{ color: blue; }}
.Person {{ color: blue; }}
Correct.
CSS
SELECT age email FROM products;
SELECT age, email FROM products;
Add comma.
SQL
assert val > 37
assert val > 37
Correct.
Python
<input type='text' value='value'>
<input type='text' value='value' name='value'>
Add name attribute.
HTML
if (val = 29)
if (val == 29)
Use ==.
C++
class Child Super:
class Child(Super):
Inheritance uses parentheses.
Python
match count {{ 1 => {{}} }}
match count {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
console.log('value'
console.log('value')
Close parenthesis.
JavaScript
["message", 35]
["message", 35]
Correct.
JSON
function process() {{ echo 'data'; }}
function process() {{ echo 'data'; }}
Correct.
PHP
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
let b = 7; b += 1;
let mut b = 7; b += 1;
Need mut to modify.
Rust
echo 'world'
echo 'world';
Add semicolon.
PHP
class Item {{ int item; }} obj.item=5;
class Item {{ public int item; }} obj.item=5;
Make field public.
Java
int &ref;
int x; int &ref = x;
Reference must be initialized.
C++
def test puts 'output' end
def test puts 'output' end
Correct.
Ruby
val bar: Int = 'world'
val bar: String = 'world'
Fix type.
Kotlin
jwt.sign({{id:99}}, 'secret');
jwt.sign({{id:99}}, 'secret', {{expiresIn:'2h'}});
Add expiration.
Node.js
for i in $(ls); do echo $i; done
for i in $(ls); do echo $i; done
Correct.
Shell
foo
foo()
Add parentheses.
Swift
println('message')
println("message")
Double quotes.
Scala
let z: Int = 'info'
let z: String = 'info'
Fix type.
Swift
<user name='hello'/>
<user name="hello"/>
Double quotes.
XML
os.sqrt(83)
import os os.sqrt(83)
Import module first.
Python
Product.save();
Product.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
// comment
/* comment */
Use /* */.
CSS
@media screen {{ body {{}} }}
@media screen {{ body {{}} }}
Correct.
CSS
for i=1,81 do print(i) end
for i=1,81 do print(i) end
Correct.
Lua
int items[100]; items[100]=5;
int items[100]; if(100<100){{}} else items[100]=5;
Bounds check.
C++
SELECT * FROM users WHRE age=66;
SELECT * FROM users WHERE age=66;
Fix WHERE.
SQL
switch(temp){{ case 41: break; }}
switch(temp){{ case 41: break; default: break; }}
Add default case.
Java
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
val = hello
val = 'hello'
Quote strings.
Python
<hr></hr>
<hr>
Self-closing.
HTML
while read line; do echo $line; done < config.json
while read line; do echo $line; done < config.json
Correct.
Shell
with open('log.txt') as fp: data = fp.read()
with open('log.txt') as fp: data = fp.read()
Correct.
Python
var x int
var x int
Correct.
Go
<center>info</center>
<div style='text-align:center;'>info</div>
Use CSS.
HTML
list[97]
if (list.indices.contains(97)) list[97]
Check index.
Kotlin
class User def method end end
class User def method end end
Correct.
Ruby
<p>world <b>data</p></b>
<p>world <b>data</b></p>
Nest properly.
HTML
function bar(): void {{ return 99; }}
function bar(): number {{ return 99; }}
Return type mismatch.
TypeScript
def bar(bar): return bar + 1
def bar(bar): return bar + 1
Correct.
Python
if ($a = 62) {{}}
if ($a -eq 62) {{}}
Use -eq.
PowerShell
SELECT COUNT(*) FROM products
SELECT COUNT(*) FROM products;
Missing semicolon.
SQL
#content {{ color: #fff; }}
#content {{ color: #fff; }}
Correct.
CSS
if (x = 28)
if (x == 28)
Use ==.
Scala
DELETE FROM items WHERE status=51
DELETE FROM items WHERE status=51;
Add semicolon.
SQL
for (int i=0; i<97; i++) {{}}
for (int i=0; i<97; i++) {{}}
Correct.
Java
if [ $val = 62 ]; then
if [ "$val" = 62 ]; then
Quote variable.
Shell
else print('test')
else: print('test')
Colon after else.
Python
cin >> count cout << count;
cin >> count; cout << count;
Add semicolon.
C++
name: value age: 44
name: value age: 44
Correct.
YAML
{ "name": "info" }
{ "name": "info" }
Correct.
JSON
[77, 75, 12
[77, 75, 12]
Close bracket.
Python