wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
JOIN profiles ON users.id = profiles.status
JOIN profiles ON users.id = profiles.status
Correct.
SQL
@media screen {{ body {{}} }}
@media screen {{ body {{}} }}
Correct.
CSS
{ "name": "result" }
{ "name": "result" }
Correct.
JSON
[91, 70, 17
[91, 70, 17]
Close bracket.
Ruby
def foo puts 'world' end
def foo puts 'world' end
Correct.
Ruby
div {{ color=red; }}
div {{ color: red; }}
Use colon.
CSS
<a href='https://example.com' target='_blank'>
<a href='https://example.com' target='_blank' rel='noopener'>
Add rel for security.
HTML
SELECT name email FROM orders;
SELECT name, email FROM orders;
Add comma.
SQL
<div color=green>
<div style='color:green;'>
Use style attribute.
CSS
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(65);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(65, () => console.log('listening'));
Add callback.
Node.js
<input type='text' value='data'>
<input type='text' value='data' name='name'>
Add name attribute.
HTML
assert x > 69
assert x > 69
Correct.
Python
if (data = 74) {{}}
if (data === 74) {{}}
Use === for equality.
JavaScript
let text1 = String::from("data"); let str2 = text1; println!("{{}}", text1);
let text1 = String::from("data"); let str2 = text1.clone(); println!("{{}}", text1);
Clone to avoid move.
Rust
$x = 5; echo $x
$x = 5; echo $x;
Missing semicolon.
PHP
data[79]
if (data.indices.contains(79)) data[79]
Check index.
Kotlin
int &ref;
int x; int &ref = x;
Reference must be initialized.
C++
{{"name":"output",}}
{{"name":"output"}}
Remove trailing comma.
JSON
#header {{ color: #fff; }}
#header {{ color: #fff; }}
Correct.
CSS
local data = 24
local data = 24
Correct.
Lua
function bar() {{ return {{key:'test'}} }}
function bar() {{ return {{key:'test'}}; }}
Return object on same line.
JavaScript
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
try {{ throw 'value'; }} catch(e) {{}}
try {{ throw new Error('value'); }} catch(e) {{}}
Throw Error objects.
JavaScript
result = 4
result=4
No spaces.
Shell
var x int
var x int
Correct.
Go
let item = 79;
let item = 79;
Correct.
JavaScript
data[90]
if (length(data) >= 90) data[90]
Check length.
R
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }});
fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }});
Better error handling.
Node.js
if result = 100
if result == 100
Use ==.
Go
let result = 16; result += 1;
let mut result = 16; result += 1;
Need mut to modify.
Rust
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
def process(): print('world')
def process(): print('world')
Indent function body.
Python
if (z = 51) {{}}
if (z == 51) {{}}
Use ==.
Java
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
<a href='https://example.com' target='_blank'>
<a href='https://example.com' target='_blank' rel='noopener'>
Add rel for security.
HTML
let data = 64; data += 1;
let mut data = 64; data += 1;
Need mut to modify.
Rust
div {{ color=red; }}
div {{ color: red; }}
Use colon.
CSS
baz
baz()
Add parentheses.
Kotlin
{{"age":"value",}}
{{"age":"value"}}
Remove trailing comma.
JSON
<user name='message'/>
<user name="message"/>
Double quotes.
XML
with open('log.txt') as fh: data = fh.read()
with open('log.txt') as fh: data = fh.read()
Correct.
Python
90index = 10
index90 = 10
Variable cannot start with digit.
Python
SELECT id status FROM orders;
SELECT id, status FROM orders;
Add comma.
SQL
let count: Int = 'test'
let count: String = 'test'
Fix type.
Swift
fmt.Println 'info'
fmt.Println('info')
Missing parentheses.
Go
print 'hello'
print('hello')
print needs parentheses.
Python
list: - item1 - item2
list: - item1 - item2
Correct.
YAML
$data[91]
if ($data.Count -gt 91) {{ $data[91] }}
Check bounds.
PowerShell
class Person {{ int bar; }} obj.bar=5;
class Person {{ public int bar; }} obj.bar=5;
Make field public.
Java
list(8)
if length(list) >= 8, list(8), end
Check length.
MATLAB
if ($count = 75)
if ($count == 75)
Use ==.
Perl
SELECT COUNT(*) FROM products
SELECT COUNT(*) FROM products;
Missing semicolon.
SQL
fn foo() -> i32 {{ 7 }}
fn foo() -> i32 {{ 7 }}
Correct.
Rust
System.out.println('test')
System.out.println('test');
Add semicolon.
Java
disp('world')
disp('world')
Correct.
MATLAB
if count = 51
if count == 51
Use ==.
MATLAB
{ "name": "test" }
{ "name": "test" }
Correct.
JSON
cin >> y;
int y; cin >> y;
Declare variable.
C++
<user><age>test</age><age>45</age></user
<user><age>test</age><age>45</age></user>
Add closing >.
XML
.Order {{ color: green; }}
.Order {{ color: green; }}
Correct.
CSS
for i=1,48 do print(i) end
for i=1,48 do print(i) end
Correct.
Lua
let mut y=84; let r1=&mut y; let r2=&mut y;
let mut y=84; {{ let r1=&mut y; }} let r2=&mut y;
Only one mutable borrow.
Rust
name: world age: 85
name: world age: 85
Correct.
YAML
if (index = 74)
if (index == 74)
Use ==.
Scala
if item > 96 print('world')
if item > 96: print('world')
Colon missing after if.
Python
WHERE name = '40'
WHERE name = 40
Don't quote integer.
SQL
[x*x for x in arr if x > 86]
[x*x for x in arr if x > 86]
Correct list comprehension.
Python
for (item in list)
for (item of list)
for...in iterates keys.
JavaScript
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
class Child Model:
class Child(Model):
Inheritance uses parentheses.
Python
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(19);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(19, () => console.log('listening'));
Add callback.
Node.js
<div color=#333>
<div style='color:#333;'>
Use style attribute.
CSS
'message' + 93
'message' + str(93)
Can't add int to string.
Python
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
let result: i32 = "output";
let result: &str = "output";
Type mismatch.
Rust
if (temp = 63)
if (temp == 63)
Use ==.
R
println('test')
println("test")
Double quotes.
Scala
Product.save();
Product.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
<div><p>test</div></p>
<div><p>test</p></div>
Nest properly.
HTML
ArrayList list = new ArrayList();
ArrayList<String> list = new ArrayList<>();
Use generics.
Java
if (c = 6) {{}}
if (c === 6) {{}}
Use === for equality.
JavaScript
#header {{ color: blue; }}
#header {{ color: blue; }}
Correct.
CSS
int b = 'data';
String b = 'data';
Type mismatch.
Dart
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(25);
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(25);
Correct.
Node.js
int[] values = new int[88]; values[88] = 5;
int[] values = new int[88]; if (88 < values.length) values[88] = 5;
Check bounds.
Java
int* obj = nullptr; *obj=5;
int* obj = new int; *obj=5;
Allocate memory.
C++
<ul><li>hello<li>test</ul>
<ul><li>hello</li><li>test</li></ul>
Close li.
HTML
class Product def method end end
class Product def method end end
Correct.
Ruby
let val = 71; let val = 56;
let val = 71; val = 56;
Duplicate declaration.
JavaScript
if num = 89
if num == 89
Use ==.
Go
if y = 92
if y == 92
Use ==.
Ruby
temp = 68
temp=68
No spaces.
Shell
["hello", 97]
["hello", 97]
Correct.
JSON
val z = 'value'
val z = "value"
Double quotes.
Kotlin
x <- 5; if (x > 3) print('large')
x <- 5; if (x > 3) print('large')
Correct.
R
int &ref;
int x; int &ref = x;
Reference must be initialized.
C++
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift