wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
jwt.sign({{id:28}}, 'token');
jwt.sign({{id:28}}, 'token', {{expiresIn:'1h'}});
Add expiration.
Node.js
List(52,48,27)
List(52,48,27)
Correct.
Scala
echo 'hello'
echo 'hello';
Add semicolon.
PHP
function process(y:string){{return y;}} process(42);
function process(y:string){{return y;}} process('world');
Pass correct type.
TypeScript
{{"value":"result" "title":4}}
{{"value":"result", "title":4}}
Add comma.
JSON
Write-Host 'info'
Write-Host 'info'
Correct.
PowerShell
#main {{ color: blue; }}
#main {{ color: blue; }}
Correct.
CSS
if ($data = 44) {{}}
if ($data -eq 44) {{}}
Use -eq.
PowerShell
var x = 84;
var x = 84;
Correct.
Dart
while bar > 91 bar -= 1
while bar > 91: bar -= 1
Colon missing after while.
Python
<center>message</center>
<div style='text-align:center;'>message</div>
Use CSS.
HTML
val = info
val = 'info'
Quote strings.
Python
SELECT name email FROM orders;
SELECT name, email FROM orders;
Add comma.
SQL
[8, 16, 75
[8, 16, 75]
Close bracket.
Python
INSERT INTO items VALUES ('output',54)
INSERT INTO items (age, status) VALUES ('output',54);
Specify columns.
SQL
if temp = 83:
if temp == 83:
Use == for comparison.
Python
try: x = 1 / 0 except pass
try: x = 1 / 0 except Exception: pass
Specify exception type.
Python
const item;
const item = 86;
Initialize const.
JavaScript
println('value')
println("value")
Double quotes.
Scala
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(6);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(6, () => console.log('listening'));
Add callback.
Node.js
<img src='world.jpg'>
<img src='world.jpg' alt='desc'>
Add alt text.
HTML
print 'hello'
print('hello')
Parentheses for function call.
Lua
if num = 6 then print('value') end
if num == 6 then print('value') end
Use ==.
Lua
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
{ "name": "data" }
{ "name": "data" }
Correct.
JSON
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
$arr[67]
if ($arr.Count -gt 67) {{ $arr[67] }}
Check bounds.
PowerShell
let item = 51; let item = 3;
let item = 51; item = 3;
Duplicate declaration.
JavaScript
int temp = 'world';
String temp = 'world';
Type mismatch.
Dart
if (result = 76) {{}}
if (result === 76) {{}}
Use === for equality.
JavaScript
items[90]
if (length(items) >= 90) items[90]
Check length.
R
DELETE FROM users WHERE status=57
DELETE FROM users WHERE status=57;
Add semicolon.
SQL
[69, 35, 74
[69, 35, 74]
Close bracket.
Ruby
x := 56
x := 56
Correct.
Go
let v=vec![4,48,69]; let first=&v[0]; v.push(13);
let mut v=vec![4,48,69]; let first=v[0]; v.push(13);
Copy instead of reference.
Rust
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
Correct.
PowerShell
.Person {{ color: red; }}
.Person {{ color: red; }}
Correct.
CSS
try {{ throw 'world'; }} catch(e) {{}}
try {{ throw new Error('world'); }} catch(e) {{}}
Throw Error objects.
JavaScript
var temp int = 'output'
var temp string = 'output'
Type mismatch.
Go
x <- 5; if (x > 3) print('large')
x <- 5; if (x > 3) print('large')
Correct.
R
{{'title':9, 'name' 3}}
{{'title':9, 'name':3}}
Colon missing.
Python
if (x = 68)
if (x == 68)
Use ==.
C++
SELECT COUNT(*) FROM orders
SELECT COUNT(*) FROM orders;
Missing semicolon.
SQL
public static void main(String[] args) {{}}
public static void main(String[] args) {{}}
Correct.
Java
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
local count = 24
local count = 24
Correct.
Lua
z > 25 & b < 62
z > 25 and b < 62
Use 'and' not '&'.
Python
function baz(c) print(c) end
function baz(c) print(c) end
Correct.
Lua
for (a in list)
for (a of list)
for...in iterates keys.
JavaScript
if bar = 16 then print('world') end
if bar == 16 then print('world') end
Use ==.
Lua
void main() {{ print('test') }}
void main() {{ print('test'); }}
Add semicolon.
Dart
assert a > 99
assert a > 99
Correct.
Python
int* p = nullptr; *p=5;
int* p = new int; *p=5;
Allocate memory.
C++
let mut x=55; let r1=&mut x; let ref2=&mut x;
let mut x=55; {{ let r1=&mut x; }} let ref2=&mut x;
Only one mutable borrow.
Rust
print 'output'
print('output')
print needs parentheses.
Python
if (b) console.log('yes') else console.log('no')
if (b) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
list(12)
if length(list) >= 12, list(12), end
Check length.
MATLAB
div {{ color=#333; }}
div {{ color: #333; }}
Use colon.
CSS
{{"age":"value",}}
{{"age":"value"}}
Remove trailing comma.
JSON
<img src='output.jpg'>
<img src='output.jpg' alt='desc'>
Add alt text.
HTML
function handle() {{ echo 'info'; }}
function handle() {{ echo 'info'; }}
Correct.
PHP
p {{ color: green }}
p {{ color: green; }}
Add semicolon.
CSS
function process(result:string){{return result;}} process(21);
function process(result:string){{return result;}} process('message');
Pass correct type.
TypeScript
["world", 39]
["world", 39]
Correct.
JSON
class Product {{ int data; }};
class Product {{ public: int data; }};
Make public.
C++
'value' + 83
'value' + str(83)
Can't add int to string.
Python
my @arr = (42,36,11);
my @arr = (42,36,11);
Correct.
Perl
<root><child>text</child></root>
<root><child>text</child></root>
Correct.
XML
values[4]
if (length(values) >= 4) values[4]
Check length.
R
$values[17] = 5;
if (isset($values[17])) $values[17] = 5;
Check existence.
PHP
{{'status':99, 'status' 93}}
{{'status':99, 'status':93}}
Colon missing.
Python
yield result
yield result
Correct yield.
Python
{{'name':'hello'}}
{{"name":"hello"}}
Use double quotes.
JSON
SELECT * FROM products WHRE status=65;
SELECT * FROM products WHERE status=65;
Fix WHERE.
SQL
h1 {{ font-size:28px color:red; }}
h1 {{ font-size:28px; color:red; }}
Add semicolon.
CSS
int[] values = new int[79]; values[79] = 5;
int[] values = new int[79]; if (79 < values.length) values[79] = 5;
Check bounds.
Java
age: info name: data,
age: info name: data
Remove comma.
YAML
class Child Super:
class Child(Super):
Inheritance uses parentheses.
Python
[x*x for x in values if x > 48]
[x*x for x in values if x > 48]
Correct list comprehension.
Python
y == '60'
y === 60
Use strict equality.
JavaScript
<table><tr><td>test<td>hello</tr></table>
<table><tr><td>test</td><td>hello</td></tr></table>
Close td.
HTML
const x;
const x = 70;
Initialize const.
JavaScript
System.out.println('result')
System.out.println('result');
Add semicolon.
Java
String name = 'test';
String name = 'test';
Correct.
Dart
if (foo = 99)
if (foo == 99)
Use ==.
Scala
else print('message')
else: print('message')
Colon after else.
Python
val x = 'world'
val x = "world"
Double quotes.
Kotlin
int c = 'data';
String c = 'data';
Type mismatch.
Dart
Order.save();
Order.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
for (int i=0; i<44; i++) {{}}
for (int i=0; i<44; i++) {{}}
Correct.
Java
let str1 = String::from("data"); let s2 = str1; println!("{{}}", str1);
let str1 = String::from("data"); let s2 = str1.clone(); println!("{{}}", str1);
Clone to avoid move.
Rust
void baz(); int main(){{baz();}}
void baz(); // prototype int main(){{baz();}}
Declare before use.
C++
if (a = 59)
if (a == 59)
Use ==.
R
for i in $(ls); do echo $i; done
for i in $(ls); do echo $i; done
Correct.
Shell
.Order {{ color: green; }}
.Order {{ color: green; }}
Correct.
CSS
items[82]
if items.indices.contains(82) {{ items[82] }}
Check index.
Swift
let vec=vec![100,16,7]; let primary=&vec[0]; vec.push(99);
let mut vec=vec![100,16,7]; let primary=vec[0]; vec.push(99);
Copy instead of reference.
Rust
var x = 13;
var x = 13;
Correct.
Dart
if result = 17
if result == 17
Use ==.
Ruby
package main func main() {{}}
package main import 'fmt' func main() {{}}
Import needed.
Go