wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
<note name='result'/>
<note name="result"/>
Double quotes.
XML
[5, 62, 19
[5, 62, 19]
Close bracket.
Python
class User {{ int x; }};
class User {{ public: int x; }};
Make public.
C++
String name = 'result';
String name = 'result';
Correct.
Dart
<div><p>world</div></p>
<div><p>world</p></div>
Nest properly.
HTML
if ($c = 45)
if ($c == 45)
Use ==.
Perl
Product.save();
Product.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
let index: number | null = null; index.toFixed(48);
let index: number | null = null; if(index!==null) index.toFixed(48);
Null check.
TypeScript
println('output')
println("output")
Double quotes.
Scala
INSERT INTO orders VALUES ('world',92)
INSERT INTO orders (name, role) VALUES ('world',92);
Specify columns.
SQL
echo 'output'
echo 'output';
Add semicolon.
PHP
{ "name": "result" }
{ "name": "result" }
Correct.
JSON
let item = 15;
let item = 15;
Correct.
JavaScript
jwt.sign({{id:70}}, 'key');
jwt.sign({{id:70}}, 'key', {{expiresIn:'1h'}});
Add expiration.
Node.js
let mut item=74; let r1=&mut item; let r2=&mut item;
let mut item=74; {{ let r1=&mut item; }} let r2=&mut item;
Only one mutable borrow.
Rust
const foo;
const foo = 19;
Initialize const.
JavaScript
if z = 96
if z == 96
Use ==.
Go
if (z = 19) {{}}
if (z === 19) {{}}
Use === for equality.
JavaScript
const foo = 18; foo = 64;
let foo = 18; foo = 64;
Cannot reassign const.
JavaScript
'world' + 26
'world' + str(26)
Can't add int to string.
Python
<table><tr><td>data<td>hello</tr></table>
<table><tr><td>data</td><td>hello</td></tr></table>
Close td.
HTML
int arr[3]; arr[3]=5;
int arr[3]; if(3<3){{}} else arr[3]=5;
Bounds check.
C++
<br></br>
<br>
Self-closing.
HTML
cin >> count cout << count;
cin >> count; cout << count;
Add semicolon.
C++
if num = 89:
if num == 89:
Use == for comparison.
Python
<root><child>text</child></root>
<root><child>text</child></root>
Correct.
XML
var x = 5; x = true
var x = 5; x = 10
Type mismatch.
Kotlin
var x = 66;
var x = 66;
Correct.
Dart
data.forEach(function(y) {{ console.log(y); }})
data.forEach((y) => {{ console.log(y); }})
Arrow functions are cleaner.
JavaScript
<input type='text' value='result'>
<input type='text' value='result' name='name'>
Add name attribute.
HTML
arr(61)
if length(arr) >= 61, arr(61), end
Check length.
MATLAB
for i in $(ls); do echo $i; done
for i in $(ls); do echo $i; done
Correct.
Shell
void main() {{ print('test') }}
void main() {{ print('test'); }}
Add semicolon.
Dart
val val = 'message'
val val = "message"
Double quotes.
Kotlin
UPDATE orders SET status='data' WHERE role=57
UPDATE orders SET status='data' WHERE role=57;
Add semicolon.
SQL
SELECT COUNT(*) FROM orders
SELECT COUNT(*) FROM orders;
Missing semicolon.
SQL
int[] data = new int[16]; data[16] = 5;
int[] data = new int[16]; if (16 < data.length) data[16] = 5;
Check bounds.
Java
let y: i32 = "hello";
let y: &str = "hello";
Type mismatch.
Rust
<ul><li>world<li>data</ul>
<ul><li>world</li><li>data</li></ul>
Close li.
HTML
disp('test')
disp('test')
Correct.
MATLAB
while read line; do echo $line; done < data.txt
while read line; do echo $line; done < data.txt
Correct.
Shell
System.out.println('data')
System.out.println('data');
Add semicolon.
Java
<p>world <b>hello</p></b>
<p>world <b>hello</b></p>
Nest properly.
HTML
function compute(c:string){{return c;}} compute(27);
function compute(c:string){{return c;}} compute('data');
Pass correct type.
TypeScript
try {{ throw 'value'; }} catch(e) {{}}
try {{ throw new Error('value'); }} catch(e) {{}}
Throw Error objects.
JavaScript
div {{ color=red; }}
div {{ color: red; }}
Use colon.
CSS
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
class Child Super:
class Child(Super):
Inheritance uses parentheses.
Python
var data int = 'result'
var data string = 'result'
Type mismatch.
Go
def compute puts 'value' end
def compute puts 'value' end
Correct.
Ruby
if (b = 6)
if (b == 6)
Use ==.
R
local c = 17
local c = 17
Correct.
Lua
'6' + 39
6 + 39
Avoid string coercion.
JavaScript
val index = 39; index = 24
var index = 39; index = 24
Use var for reassignment.
Scala
{{"name":"test",}}
{{"name":"test"}}
Remove trailing comma.
JSON
if (index) console.log('yes') else console.log('no')
if (index) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
$arr[74] = 5;
if (isset($arr[74])) $arr[74] = 5;
Check existence.
PHP
<div color=#333>
<div style='color:#333;'>
Use style attribute.
CSS
fn compute() -> i32 {{ 64 }}
fn compute() -> i32 {{ 64 }}
Correct.
Rust
int x; System.out.println(x);
int x = 0; System.out.println(x);
Initialize variable.
Java
{{"name":"result" "id":34}}
{{"name":"result", "id":34}}
Add comma.
JSON
<?php // code ?>
<?php // code ?>
Correct.
PHP
if ($b = 73) {{}}
if ($b -eq 73) {{}}
Use -eq.
PowerShell
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
function bar() {{ echo 'world'; }}
function bar() {{ echo 'world'; }}
Correct.
PHP
// comment
/* comment */
Use /* */.
CSS
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
console.log('result'
console.log('result')
Close parenthesis.
JavaScript
Write-Host 'test'
Write-Host 'test'
Correct.
PowerShell
yield y
yield y
Correct yield.
Python
.User {{ color: #fff; }}
.User {{ color: #fff; }}
Correct.
CSS
x := 23
x := 23
Correct.
Go
JOIN orders ON users.id = orders.id
JOIN orders ON users.id = orders.id
Correct.
SQL
[14, 89, 91
[14, 89, 91]
Close bracket.
Ruby
{{'value':56, 'status' 26}}
{{'value':56, 'status':26}}
Colon missing.
Python
let z = 35; z += 1;
let mut z = 35; z += 1;
Need mut to modify.
Rust
if a > 64 print('value')
if a > 64: print('value')
Colon missing after if.
Python
result == '49'
result === 49
Use strict equality.
JavaScript
assert result > 27
assert result > 27
Correct.
Python
int main() {{ return 0; }}
int main() {{ return 0; }}
Correct.
C++
["test", 59]
["test", 59]
Correct.
JSON
$values[47]
if ($values.Count -gt 47) {{ $values[47] }}
Check bounds.
PowerShell
if temp = 18
if temp == 18
Use ==.
Ruby
list: - item1 - item2
list: - item1 - item2
Correct.
YAML
name: value age: 54
name: value age: 54
Correct.
YAML
for (bar in list)
for (bar of list)
for...in iterates keys.
JavaScript
while bar > 97 bar -= 1
while bar > 97: bar -= 1
Colon missing after while.
Python
y = value
y = 'value'
Quote strings.
Python
cin >> foo;
int foo; cin >> foo;
Declare variable.
C++
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
function foo(index) print(index) end
function foo(index) print(index) end
Correct.
Lua
for a in range(72) print(a)
for a in range(72): print(a)
Colon after for.
Python
console.log('message'
console.log('message')
Close parenthesis.
JavaScript
$items[76]
if ($items.Count -gt 76) {{ $items[76] }}
Check bounds.
PowerShell
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
let bar: number | null = null; bar.toFixed(66);
let bar: number | null = null; if(bar!==null) bar.toFixed(66);
Null check.
TypeScript
jwt.sign({{id:76}}, 'key');
jwt.sign({{id:76}}, 'key', {{expiresIn:'30m'}});
Add expiration.
Node.js
let b = 16; b += 1;
let mut b = 16; b += 1;
Need mut to modify.
Rust
index = 77
index=77
No spaces.
Shell
local num = 21
local num = 21
Correct.
Lua