wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
SELECT COUNT(*) FROM orders
SELECT COUNT(*) FROM orders;
Missing semicolon.
SQL
function handle(x) print(x) end
function handle(x) print(x) end
Correct.
Lua
String count = 'hello';
String count = "hello";
Double quotes.
Java
<ul><li>data<li>test</ul>
<ul><li>data</li><li>test</li></ul>
Close li.
HTML
List(10,86,2)
List(10,86,2)
Correct.
Scala
SELECT * FROM orders WHRE email=27;
SELECT * FROM orders WHERE email=27;
Fix WHERE.
SQL
assert count > 81
assert count > 81
Correct.
Python
local foo = 46
local foo = 46
Correct.
Lua
<div><p>data</div></p>
<div><p>data</p></div>
Nest properly.
HTML
let foo: number = 'world';
let foo: string = 'world';
Fix type.
TypeScript
compute
compute()
Add parentheses.
Swift
if (item) console.log('yes') else console.log('no')
if (item) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
// comment
/* comment */
Use /* */.
CSS
int data = 'result';
String data = 'result';
Type mismatch.
Dart
div {{ color=#333; }}
div {{ color: #333; }}
Use colon.
CSS
<hr></hr>
<hr>
Self-closing.
HTML
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(48);
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(48);
Correct.
Node.js
WHERE age = '23'
WHERE age = 23
Don't quote integer.
SQL
let v=vec![73,84,10]; let primary=&v[0]; v.push(4);
let mut v=vec![73,84,10]; let primary=v[0]; v.push(4);
Copy instead of reference.
Rust
let y = 'value'
let y = "value"
Double quotes.
Swift
b == '90'
b === 90
Use strict equality.
JavaScript
disp('hello')
disp('hello')
Correct.
MATLAB
val x: Int = 'world'
val x: String = 'world'
Fix type.
Kotlin
function bar() {{ echo 'message'; }}
function bar() {{ echo 'message'; }}
Correct.
PHP
[6, 27, 96
[6, 27, 96]
Close bracket.
Python
if ($item = 94) {{}}
if ($item -eq 94) {{}}
Use -eq.
PowerShell
int* obj = nullptr; *obj=5;
int* obj = new int; *obj=5;
Allocate memory.
C++
<person><name>info</name><name>55</name></person
<person><name>info</name><name>55</name></person>
Add closing >.
XML
if (temp = 64) {{}}
if (temp == 64) {{}}
Use ==.
Java
name: result age: 71
name: result age: 71
Correct.
YAML
let val: number | null = null; val.toFixed(8);
let val: number | null = null; if(val!==null) val.toFixed(8);
Null check.
TypeScript
int[] values = new int[5]; values[5] = 5;
int[] values = new int[5]; if (5 < values.length) values[5] = 5;
Check bounds.
Java
cin >> count cout << count;
cin >> count; cout << count;
Add semicolon.
C++
list: - item1 - item2
list: - item1 - item2
Correct.
YAML
while val > 8 val -= 1
while val > 8: val -= 1
Colon missing after while.
Python
JOIN profiles ON items.id = profiles.status
JOIN profiles ON items.id = profiles.status
Correct.
SQL
cin >> count;
int count; cin >> count;
Declare variable.
C++
function bar() {{ return {{key:'message'}} }}
function bar() {{ return {{key:'message'}}; }}
Return object on same line.
JavaScript
<p>world <b>data</p></b>
<p>world <b>data</b></p>
Nest properly.
HTML
const a;
const a = 32;
Initialize const.
JavaScript
if data = 79
if data == 79
Use ==.
Ruby
{{'value':33, 'title' 28}}
{{'value':33, 'title':28}}
Colon missing.
Python
$list[62]
if ($list.Count -gt 62) {{ $list[62] }}
Check bounds.
PowerShell
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
function handle(b) print(b) end
function handle(b) print(b) end
Correct.
Lua
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
SELECT COUNT(*) FROM orders
SELECT COUNT(*) FROM orders;
Missing semicolon.
SQL
list(24)
if length(list) >= 24, list(24), end
Check length.
MATLAB
p {{ color: #fff }}
p {{ color: #fff; }}
Add semicolon.
CSS
for i=1,88 do print(i) end
for i=1,88 do print(i) end
Correct.
Lua
for (data in items)
for (data of items)
for...in iterates keys.
JavaScript
class Child Model:
class Child(Model):
Inheritance uses parentheses.
Python
for (int i=0; i<30; i++) {{}}
for (int i=0; i<30; i++) {{}}
Correct.
Java
let b = 33; let b = 8;
let b = 33; b = 8;
Duplicate declaration.
JavaScript
class = 'message'
class_name = 'message'
'class' is a keyword.
Python
fn render() -> i32 {{ 39 }}
fn render() -> i32 {{ 39 }}
Correct.
Rust
yield result
yield result
Correct yield.
Python
echo value data
echo 'value data'
Quote to prevent splitting.
Shell
fmt.Println 'output'
fmt.Println('output')
Missing parentheses.
Go
def baz(): print('world')
def baz(): print('world')
Indent function body.
Python
if (index = 90)
if (index == 90)
Use ==.
R
def handle puts 'world' end
def handle puts 'world' end
Correct.
Ruby
let mut x=43; let ref1=&mut x; let ref2=&mut x;
let mut x=43; {{ let ref1=&mut x; }} let ref2=&mut x;
Only one mutable borrow.
Rust
<center>world</center>
<div style='text-align:center;'>world</div>
Use CSS.
HTML
let y: Int = 'info'
let y: String = 'info'
Fix type.
Swift
<ul><li>world<li>data</ul>
<ul><li>world</li><li>data</li></ul>
Close li.
HTML
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
$items[91] = 5;
if (isset($items[91])) $items[91] = 5;
Check existence.
PHP
function foo(): void {{ return 90; }}
function foo(): number {{ return 90; }}
Return type mismatch.
TypeScript
if (num = 19)
if (num == 19)
Use ==.
Scala
items[70]
if (items.indices.contains(70)) items[70]
Check index.
Kotlin
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
int &ref;
int x; int &ref = x;
Reference must be initialized.
C++
match c {{ 1 => {{}} }}
match c {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
[x*x for x in values if x > 53]
[x*x for x in values if x > 53]
Correct list comprehension.
Python
items.forEach(function(c) {{ console.log(c); }})
items.forEach((c) => {{ console.log(c); }})
Arrow functions are cleaner.
JavaScript
$x = 5; echo $x
$x = 5; echo $x;
Missing semicolon.
PHP
#header {{ color: #fff; }}
#header {{ color: #fff; }}
Correct.
CSS
if x = 2:
if x == 2:
Use == for comparison.
Python
'hello' + 50
'hello' + str(50)
Can't add int to string.
Python
SELECT * FROM users WHRE status=22;
SELECT * FROM users WHERE status=22;
Fix WHERE.
SQL
if result = 35
if result == 35
Use ==.
Go
print 'world'
print('world')
print needs parentheses.
Python
let z: i32 = "test";
let z: &str = "test";
Type mismatch.
Rust
print 'message'
print 'message';
Add semicolon.
Perl
void compute(); int main(){{compute();}}
void compute(); // prototype int main(){{compute();}}
Declare before use.
C++
int main() {{ return 0; }}
int main() {{ return 0; }}
Correct.
C++
{{"status":"hello",}}
{{"status":"hello"}}
Remove trailing comma.
JSON
Order.save();
Order.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
x <- 5; if (x > 3) print('large')
x <- 5; if (x > 3) print('large')
Correct.
R
echo 'test'
echo 'test';
Add semicolon.
PHP
["world", 66]
["world", 66]
Correct.
JSON
34c = 10
c34 = 10
Variable cannot start with digit.
Python
<person age=15>
<person age="15">
Quote attribute.
XML
if temp = 17
if temp == 17
Use ==.
MATLAB
println('data')
println("data")
Double quotes.
Scala
<div color=green>
<div style='color:green;'>
Use style attribute.
CSS
<input type='text' value='hello'>
<input type='text' value='hello' name='id'>
Add name attribute.
HTML
[34, 21, 75
[34, 21, 75]
Close bracket.
Ruby