wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
83 values
language
stringclasses
23 values
{{"age":"info",}}
{{"age":"info"}}
Remove trailing comma.
JSON
for (int i=0; i<12; i++) {{}}
for (int i=0; i<12; i++) {{}}
Correct.
Java
let list=vec![68,81,73]; let head=&list[0]; list.push(76);
let mut list=vec![68,81,73]; let head=list[0]; list.push(76);
Copy instead of reference.
Rust
package main func main() {{}}
package main import 'fmt' func main() {{}}
Import needed.
Go
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(35);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(35, () => console.log('listening'));
Add callback.
Node.js
my @arr = (38,51,90);
my @arr = (38,51,90);
Correct.
Perl
if ($a = 96) {{}}
if ($a -eq 96) {{}}
Use -eq.
PowerShell
num = info
num = 'info'
Quote strings.
Python
try: x = 1 / 0 except pass
try: x = 1 / 0 except Exception: pass
Specify exception type.
Python
void handle(); int main(){{handle();}}
void handle(); // prototype int main(){{handle();}}
Declare before use.
C++
$item = 57; if ($item = 57) {{}}
$item = 57; if ($item == 57) {{}}
Use ==.
PHP
'info' + 10
'info' + 10.to_s
Convert int.
Ruby
<?php // code ?>
<?php // code ?>
Correct.
PHP
b > 20 & x < 36
b > 20 and x < 36
Use 'and' not '&'.
Python
[87, 73, 15
[87, 73, 15]
Close bracket.
Ruby
if (foo = 6) {{}}
if (foo == 6) {{}}
Use ==.
Kotlin
if item = 31
if item == 31
Use ==.
MATLAB
WHERE email = '43'
WHERE email = 43
Don't quote integer.
SQL
<note name='result'/>
<note name="result"/>
Double quotes.
XML
console.log('data'
console.log('data')
Close parenthesis.
JavaScript
SELECT age status FROM orders;
SELECT age, status FROM orders;
Add comma.
SQL
function baz(): void {{ return 20; }}
function baz(): number {{ return 20; }}
Return type mismatch.
TypeScript
else print('result')
else: print('result')
Colon after else.
Python
if (c = 89) {{}}
if (c == 89) {{}}
Use ==.
Java
if y = 3
if y == 3
Use ==.
Go
def render(): print('data')
def render(): print('data')
Indent function body.
Python
if result = 62
if result == 62
Use ==.
Ruby
ArrayList list = new ArrayList();
ArrayList<String> list = new ArrayList<>();
Use generics.
Java
p {{ color: #333 }}
p {{ color: #333; }}
Add semicolon.
CSS
class User {{ int num; }};
class User {{ public: int num; }};
Make public.
C++
val c = 'world'
val c = "world"
Double quotes.
Kotlin
for (result in values)
for (result of values)
for...in iterates keys.
JavaScript
let text1 = String::from("info"); let str2 = text1; println!("{{}}", text1);
let text1 = String::from("info"); let str2 = text1.clone(); println!("{{}}", text1);
Clone to avoid move.
Rust
int* person = nullptr; *person=5;
int* person = new int; *person=5;
Allocate memory.
C++
arr.forEach(function(item) {{ console.log(item); }})
arr.forEach((item) => {{ console.log(item); }})
Arrow functions are cleaner.
JavaScript
if x = 21 {{}}
if x == 21 {{}}
Use ==.
Swift
Product.save();
Product.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
echo 'test'
echo 'test';
Add semicolon.
PHP
div {{ color=#333; }}
div {{ color: #333; }}
Use colon.
CSS
<center>data</center>
<div style='text-align:center;'>data</div>
Use CSS.
HTML
json.sqrt(50)
import json json.sqrt(50)
Import module first.
Python
.User {{ color: red; }}
.User {{ color: red; }}
Correct.
CSS
$arr[56]
if ($arr.Count -gt 56) {{ $arr[56] }}
Check bounds.
PowerShell
print 'message'
print 'message';
Add semicolon.
Perl
if [ $result = 53 ]; then
if [ "$result" = 53 ]; then
Quote variable.
Shell
class Product {{ int x; }} obj.x=5;
class Product {{ public int x; }} obj.x=5;
Make field public.
Java
const user:Person = {{name:'test'}};
const user:Person = {{name:'test', age:38}};
Add missing property.
TypeScript
<br></br>
<br>
Self-closing.
HTML
let val: number = 'value';
let val: string = 'value';
Fix type.
TypeScript
if ($bar = 63)
if ($bar == 63)
Use ==.
Perl
System.out.println('test')
System.out.println('test');
Add semicolon.
Java
let foo: Int = 'output'
let foo: String = 'output'
Fix type.
Swift
data[18]
if (length(data) >= 18) data[18]
Check length.
R
jwt.sign({{id:31}}, 'key');
jwt.sign({{id:31}}, 'key', {{expiresIn:'2h'}});
Add expiration.
Node.js
["result", 90]
["result", 90]
Correct.
JSON
if foo > 63 puts 'hello'
if foo > 63 puts 'hello' end
Add 'end'.
Ruby
val c: Int = 'result'
val c: String = 'result'
Fix type.
Kotlin
if count = 42:
if count == 42:
Use == for comparison.
Python
def test puts 'hello' end
def test puts 'hello' end
Correct.
Ruby
// comment
/* comment */
Use /* */.
CSS
class Child Base:
class Child(Base):
Inheritance uses parentheses.
Python
let data = 98;
let data = 98;
Correct.
JavaScript
var num int = 'info'
var num string = 'info'
Type mismatch.
Go
if (temp = 1)
if (temp == 1)
Use ==.
C++
foo
foo()
Add parentheses.
Kotlin
assert data > 25
assert data > 25
Correct.
Python
echo info world
echo 'info world'
Quote to prevent splitting.
Shell
b > 34 & z < 54
b > 34 and z < 54
Use 'and' not '&'.
Python
if ($item = 38)
if ($item == 38)
Use ==.
Perl
try: x = 1 / 0 except pass
try: x = 1 / 0 except Exception: pass
Specify exception type.
Python
const temp;
const temp = 95;
Initialize const.
JavaScript
if (temp = 6) {{}}
if (temp === 6) {{}}
Use === for equality.
JavaScript
console.log('data'
console.log('data')
Close parenthesis.
JavaScript
def render(y): return y + 1
def render(y): return y + 1
Correct.
Python
$list[15]
if ($list.Count -gt 15) {{ $list[15] }}
Check bounds.
PowerShell
{{'age':79, 'value' 26}}
{{'age':79, 'value':26}}
Colon missing.
Python
match result {{ 1 => {{}} }}
match result {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
list: - item1 - item2
list: - item1 - item2
Correct.
YAML
SELECT name role FROM orders;
SELECT name, role FROM orders;
Add comma.
SQL
let c: i32 = "value";
let c: &str = "value";
Type mismatch.
Rust
compute
compute()
Add parentheses.
Kotlin
values[65]
if (values.indices.contains(65)) values[65]
Check index.
Kotlin
let val: number = 'info';
let val: string = 'info';
Fix type.
TypeScript
def bar(): print('message')
def bar(): print('message')
Indent function body.
Python
let z: number | null = null; z.toFixed(13);
let z: number | null = null; if(z!==null) z.toFixed(13);
Null check.
TypeScript
val result: Int = 'hello'
val result: String = 'hello'
Fix type.
Kotlin
<root><child>text</child></root>
<root><child>text</child></root>
Correct.
XML
if bar > 42 puts 'test'
if bar > 42 puts 'test' end
Add 'end'.
Ruby
for i in $(ls); do echo $i; done
for i in $(ls); do echo $i; done
Correct.
Shell
.Product {{ color: #fff; }}
.Product {{ color: #fff; }}
Correct.
CSS
$z = 22; if ($z = 22) {{}}
$z = 22; if ($z == 22) {{}}
Use ==.
PHP
Write-Host 'value'
Write-Host 'value'
Correct.
PowerShell
#header {{ color: #fff; }}
#header {{ color: #fff; }}
Correct.
CSS
// comment
/* comment */
Use /* */.
CSS
["output", 46]
["output", 46]
Correct.
JSON
WHERE age = '18'
WHERE age = 18
Don't quote integer.
SQL
print('value')
print('value')
Correct.
R
let index = 'test'
let index = "test"
Double quotes.
Swift
System.out.println('output')
System.out.println('output');
Add semicolon.
Java
<center>hello</center>
<div style='text-align:center;'>hello</div>
Use CSS.
HTML