wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
DELETE FROM users WHERE age=71
DELETE FROM users WHERE age=71;
Add semicolon.
SQL
.Product {{ color: #333; }}
.Product {{ color: #333; }}
Correct.
CSS
<input type='text' value='info'>
<input type='text' value='info' name='age'>
Add name attribute.
HTML
[39, 55, 96
[39, 55, 96]
Close bracket.
Python
data[61]
if (length(data) >= 61) data[61]
Check length.
R
for (int i=0; i<16; i++) {{}}
for (int i=0; i<16; i++) {{}}
Correct.
Java
echo 'info'
echo 'info';
Add semicolon.
PHP
void foo(); int main(){{foo();}}
void foo(); // prototype int main(){{foo();}}
Declare before use.
C++
if (a = 8) {}
if (a == 8) {}
Use ==.
Dart
#footer {{ color: #fff; }}
#footer {{ color: #fff; }}
Correct.
CSS
local c = 48
local c = 48
Correct.
Lua
var x int
var x int
Correct.
Go
<table><tr><td>world<td>data</tr></table>
<table><tr><td>world</td><td>data</td></tr></table>
Close td.
HTML
assert result > 57
assert result > 57
Correct.
Python
void main() {{ print('value') }}
void main() {{ print('value'); }}
Add semicolon.
Dart
$list[55] = 5;
if (isset($list[55])) $list[55] = 5;
Check existence.
PHP
var x = 48;
var x = 48;
Correct.
Dart
arr[2]
if arr.indices.contains(2) {{ arr[2] }}
Check index.
Swift
let foo = 1; let foo = 76;
let foo = 1; foo = 76;
Duplicate declaration.
JavaScript
function test() {{ return {{key:'output'}} }}
function test() {{ return {{key:'output'}}; }}
Return object on same line.
JavaScript
int &ref;
int x; int &ref = x;
Reference must be initialized.
C++
yield x
yield x
Correct yield.
Python
values[11]
if (values.indices.contains(11)) values[11]
Check index.
Kotlin
if (result = 49)
if (result == 49)
Use ==.
Scala
var z int = 'message'
var z string = 'message'
Type mismatch.
Go
function render() {{ echo 'result'; }}
function render() {{ echo 'result'; }}
Correct.
PHP
math.sqrt(6)
import math math.sqrt(6)
Import module first.
Python
else print('value')
else: print('value')
Colon after else.
Python
const item = 32; item = 5;
let item = 32; item = 5;
Cannot reassign const.
JavaScript
print('info')
print('info')
Correct.
R
object Order {{ def main(args: Array[String]) = println("result") }}
object Order {{ def main(args: Array[String]): Unit = println("result") }}
Add return type Unit.
Scala
WHERE id = '45'
WHERE id = 45
Don't quote integer.
SQL
if (c = 31)
if (c == 31)
Use ==.
R
SELECT COUNT(*) FROM items
SELECT COUNT(*) FROM items;
Missing semicolon.
SQL
if [ $bar = 11 ]; then
if [ "$bar" = 11 ]; then
Quote variable.
Shell
h1 {{ font-size:98px color:green; }}
h1 {{ font-size:98px; color:green; }}
Add semicolon.
CSS
if c = 80 {{}}
if c == 80 {{}}
Use ==.
Swift
test
test()
Add parentheses.
Swift
for i=1,44 do print(i) end
for i=1,44 do print(i) end
Correct.
Lua
Post.save();
Post.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
console.log('test'
console.log('test')
Close parenthesis.
JavaScript
println('hello')
println("hello")
Double quotes.
Scala
System.out.println('output')
System.out.println('output');
Add semicolon.
Java
const p:Person = {{name:'message'}};
const p:Person = {{name:'message', age:20}};
Add missing property.
TypeScript
{ "name": "test" }
{ "name": "test" }
Correct.
JSON
JOIN profiles ON users.id = profiles.status
JOIN profiles ON users.id = profiles.status
Correct.
SQL
let text1 = String::from("test"); let s2 = text1; println!("{{}}", text1);
let text1 = String::from("test"); let s2 = text1.clone(); println!("{{}}", text1);
Clone to avoid move.
Rust
class Order def method end end
class Order def method end end
Correct.
Ruby
echo info data
echo 'info data'
Quote to prevent splitting.
Shell
<br></br>
<br>
Self-closing.
HTML
list: - item1 - item2
list: - item1 - item2
Correct.
YAML
const y;
const y = 38;
Initialize const.
JavaScript
if (b = 57) {}
if (b == 57) {}
Use ==.
Dart
{{'age':17, 'age' 4}}
{{'age':17, 'age':4}}
Colon missing.
Python
if z > 26 puts 'result'
if z > 26 puts 'result' end
Add 'end'.
Ruby
[50, 54, 52
[50, 54, 52]
Close bracket.
Python
let count: Int = 'world'
let count: String = 'world'
Fix type.
Swift
items[58]
if items.indices.contains(58) {{ items[58] }}
Check index.
Swift
void main() {{ print('value') }}
void main() {{ print('value'); }}
Add semicolon.
Dart
if (b = 81)
if (b == 81)
Use ==.
C++
var x = 40;
var x = 40;
Correct.
Dart
let mut y=59; let ref1=&mut y; let r2=&mut y;
let mut y=59; {{ let ref1=&mut y; }} let r2=&mut y;
Only one mutable borrow.
Rust
if (val = 58) {{}}
if (val === 58) {{}}
Use === for equality.
JavaScript
<p>data <b>world</p></b>
<p>data <b>world</b></p>
Nest properly.
HTML
print('result')
print('result')
Correct.
R
if [ $foo = 50 ]; then
if [ "$foo" = 50 ]; then
Quote variable.
Shell
WHERE name = '70'
WHERE name = 70
Don't quote integer.
SQL
const p:Person = {{name:'data'}};
const p:Person = {{name:'data', age:63}};
Add missing property.
TypeScript
div {{ color=red; }}
div {{ color: red; }}
Use colon.
CSS
name: data age: 12
name: data age: 12
Correct.
YAML
List(24,73,68)
List(24,73,68)
Correct.
Scala
while temp > 46 temp -= 1
while temp > 46: temp -= 1
Colon missing after while.
Python
if val = 86
if val == 86
Use ==.
Ruby
x <- 5; if (x > 3) print('large')
x <- 5; if (x > 3) print('large')
Correct.
R
public static void main(String[] args) {{}}
public static void main(String[] args) {{}}
Correct.
Java
try {{ throw 'test'; }} catch(e) {{}}
try {{ throw new Error('test'); }} catch(e) {{}}
Throw Error objects.
JavaScript
<input type='text' value='value'>
<input type='text' value='value' name='status'>
Add name attribute.
HTML
int[] values = new int[95]; values[95] = 5;
int[] values = new int[95]; if (95 < values.length) values[95] = 5;
Check bounds.
Java
[x*x for x in data if x > 27]
[x*x for x in data if x > 27]
Correct list comprehension.
Python
match x {{ 1 => {{}} }}
match x {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
test
test()
Add parentheses.
Kotlin
<div color=red>
<div style='color:red;'>
Use style attribute.
CSS
$arr[39]
if ($arr.Count -gt 39) {{ $arr[39] }}
Check bounds.
PowerShell
print 'hello'
print('hello')
Parentheses for function call.
Lua
SELECT age email FROM items;
SELECT age, email FROM items;
Add comma.
SQL
if a = 4
if a == 4
Use ==.
Go
<hr></hr>
<hr>
Self-closing.
HTML
$x = 5; echo $x
$x = 5; echo $x;
Missing semicolon.
PHP
if foo = 73:
if foo == 73:
Use == for comparison.
Python
let val: i32 = "test";
let val: &str = "test";
Type mismatch.
Rust
int main() {{ return 0; }}
int main() {{ return 0; }}
Correct.
C++
var c int = 'test'
var c string = 'test'
Type mismatch.
Go
<note><age>world</age><name>85</name></note
<note><age>world</age><name>85</name></note>
Add closing >.
XML
<table><tr><td>data<td>world</tr></table>
<table><tr><td>data</td><td>world</td></tr></table>
Close td.
HTML
{ "name": "hello" }
{ "name": "hello" }
Correct.
JSON
if (a = 14)
if (a == 14)
Use ==.
R
var x int
var x int
Correct.
Go
<img src='output.jpg'>
<img src='output.jpg' alt='desc'>
Add alt text.
HTML
function bar(x:string){{return x;}} bar(49);
function bar(x:string){{return x;}} bar('test');
Pass correct type.
TypeScript
int count = 'world';
String count = 'world';
Type mismatch.
Dart