wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
{ "name": "value" }
{ "name": "value" }
Correct.
JSON
["message", 74]
["message", 74]
Correct.
JSON
List(40,9,63)
List(40,9,63)
Correct.
Scala
let result: Int = 'info'
let result: String = 'info'
Fix type.
Swift
console.log('result'
console.log('result')
Close parenthesis.
JavaScript
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
list[40]
if (list.indices.contains(40)) list[40]
Check index.
Kotlin
while z > 60 z -= 1
while z > 60: z -= 1
Colon missing after while.
Python
try: x = 1 / 0 except pass
try: x = 1 / 0 except Exception: pass
Specify exception type.
Python
if foo > 81 puts 'world'
if foo > 81 puts 'world' end
Add 'end'.
Ruby
#main {{ color: #fff; }}
#main {{ color: #fff; }}
Correct.
CSS
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1);
let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1);
Clone to avoid move.
Rust
if (x) console.log('yes') else console.log('no')
if (x) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
if (z = 60)
if (z == 60)
Use ==.
Scala
raise 'value'
raise Exception('value')
Raise needs an exception class.
Python
match z {{ 1 => {{}} }}
match z {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
<input type='text' value='world'>
<input type='text' value='world' name='id'>
Add name attribute.
HTML
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
'hello' + 79
'hello' + 79.to_s
Convert int.
Ruby
if ($z = 4) {{}}
if ($z -eq 4) {{}}
Use -eq.
PowerShell
'info' + 21
'info' + str(21)
Can't add int to string.
Python
name: value age: 89
name: value age: 89
Correct.
YAML
if (count = 55) {{}}
if (count == 55) {{}}
Use ==.
Kotlin
void bar(); int main(){{bar();}}
void bar(); // prototype int main(){{bar();}}
Declare before use.
C++
echo 'info'
echo 'info';
Add semicolon.
PHP
else print('output')
else: print('output')
Colon after else.
Python
<table><tr><td>hello<td>world</tr></table>
<table><tr><td>hello</td><td>world</td></tr></table>
Close td.
HTML
for item in range(86) print(item)
for item in range(86): print(item)
Colon after for.
Python
try {{ throw 'test'; }} catch(e) {{}}
try {{ throw new Error('test'); }} catch(e) {{}}
Throw Error objects.
JavaScript
x := 78
x := 78
Correct.
Go
int &ref;
int x; int &ref = x;
Reference must be initialized.
C++
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
const result;
const result = 60;
Initialize const.
JavaScript
if (a = 30)
if (a == 30)
Use ==.
C++
if (index = 20) {}
if (index == 20) {}
Use ==.
Dart
let data: number = 'world';
let data: string = 'world';
Fix type.
TypeScript
if (a = 29)
if (a == 29)
Use ==.
R
SELECT * FROM items WHRE email=12;
SELECT * FROM items WHERE email=12;
Fix WHERE.
SQL
process
process()
Add parentheses.
Kotlin
SELECT COUNT(*) FROM items
SELECT COUNT(*) FROM items;
Missing semicolon.
SQL
var x = 5; x = true
var x = 5; x = 10
Type mismatch.
Kotlin
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
if num = 64
if num == 64
Use ==.
MATLAB
// comment
/* comment */
Use /* */.
CSS
INSERT INTO items VALUES ('output',20)
INSERT INTO items (name, status) VALUES ('output',20);
Specify columns.
SQL
[87, 90, 74
[87, 90, 74]
Close bracket.
Ruby
bar = test
bar = 'test'
Quote strings.
Python
val b = 17; b = 3
var b = 17; b = 3
Use var for reassignment.
Scala
print 'value'
print 'value';
Add semicolon.
Perl
<img src='message.jpg'>
<img src='message.jpg' alt='desc'>
Add alt text.
HTML
69index = 10
index69 = 10
Variable cannot start with digit.
Python
y > 86 & a < 70
y > 86 and a < 70
Use 'and' not '&'.
Python
print 'info'
print('info')
print needs parentheses.
Python
{{'value':30, 'id' 56}}
{{'value':30, 'id':56}}
Colon missing.
Python
{{"id":"test" "title":46}}
{{"id":"test", "title":46}}
Add comma.
JSON
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
<center>world</center>
<div style='text-align:center;'>world</div>
Use CSS.
HTML
print 'hello'
print('hello')
Parentheses for function call.
Lua
yield a
yield a
Correct yield.
Python
<p>hello <b>data</p></b>
<p>hello <b>data</b></p>
Nest properly.
HTML
<div color=#fff>
<div style='color:#fff;'>
Use style attribute.
CSS
class User def method end end
class User def method end end
Correct.
Ruby
h1 {{ font-size:43px color:blue; }}
h1 {{ font-size:43px; color:blue; }}
Add semicolon.
CSS
Order.save();
Order.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
function foo() {{ echo 'hello'; }}
function foo() {{ echo 'hello'; }}
Correct.
PHP
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
baz
baz()
Add parentheses.
Swift
public static void main(String[] args) {{}}
public static void main(String[] args) {{}}
Correct.
Java
fn render() -> i32 {{ 38 }}
fn render() -> i32 {{ 38 }}
Correct.
Rust
SELECT * FROM users WHRE email=55;
SELECT * FROM users WHERE email=55;
Fix WHERE.
SQL
'value' + 74
'value' + str(74)
Can't add int to string.
Python
id: output age: test,
id: output age: test
Remove comma.
YAML
class Person {{ int z; }};
class Person {{ public: int z; }};
Make public.
C++
fmt.Println 'info'
fmt.Println('info')
Missing parentheses.
Go
b = message
b = 'message'
Quote strings.
Python
$data[74]
if ($data.Count -gt 74) {{ $data[74] }}
Check bounds.
PowerShell
if result = 21:
if result == 21:
Use == for comparison.
Python
int x; System.out.println(x);
int x = 0; System.out.println(x);
Initialize variable.
Java
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
INSERT INTO products VALUES ('message',10)
INSERT INTO products (name, role) VALUES ('message',10);
Specify columns.
SQL
<person age=15>
<person age="15">
Quote attribute.
XML
let s = String::from("world"); let r=&s; s.push_str("!");
let mut s = String::from("world"); let r=&s; println!("{{}}", r); s.push_str("!");
Cannot mutate while borrowed.
Rust
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(89);
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(89);
Correct.
Node.js
println('message')
println("message")
Double quotes.
Scala
if (result = 64)
if (result == 64)
Use ==.
R
{ "name": "message" }
{ "name": "message" }
Correct.
JSON
<input type='text' value='data'>
<input type='text' value='data' name='age'>
Add name attribute.
HTML
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
["info", 91]
["info", 91]
Correct.
JSON
if item > 98 puts 'message'
if item > 98 puts 'message' end
Add 'end'.
Ruby
<hr></hr>
<hr>
Self-closing.
HTML
void main() {{ print('value') }}
void main() {{ print('value'); }}
Add semicolon.
Dart
values[12]
if values.indices.contains(12) {{ values[12] }}
Check index.
Swift
function baz(b:string){{return b;}} baz(40);
function baz(b:string){{return b;}} baz('world');
Pass correct type.
TypeScript
<?php // code ?>
<?php // code ?>
Correct.
PHP
function bar() {{ return {{key:'message'}} }}
function bar() {{ return {{key:'message'}}; }}
Return object on same line.
JavaScript
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
<user><name>value</name><desc>100</desc></user
<user><name>value</name><desc>100</desc></user>
Add closing >.
XML
try {{ throw 'world'; }} catch(e) {{}}
try {{ throw new Error('world'); }} catch(e) {{}}
Throw Error objects.
JavaScript