wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
age: hello
age: test, | age: hello
age: test | Remove comma. | YAML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let vec=vec![69,93,18]; let primary=&vec[0]; vec.push(80); | let mut vec=vec![69,93,18]; let primary=vec[0]; vec.push(80); | Copy instead of reference. | Rust |
a = world | a = 'world' | Quote strings. | Python |
print('data') | print('data') | Correct. | R |
let c: i32 = "test"; | let c: &str = "test"; | Type mismatch. | Rust |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const val; | const val = 83; | Initialize const. | JavaScript |
if x = 87: | if x == 87: | Use == for comparison. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:60}}; | Add missing property. | TypeScript |
[89, 80, 36 | [89, 80, 36] | Close bracket. | Ruby |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
def process():
print('data') | def process():
print('data') | Indent function body. | Python |
if (b = 66) {{}} | if (b == 66) {{}} | Use ==. | Java |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
if (item = 37) | if (item == 37) | Use ==. | R |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
'test' + 13 | 'test' + str(13) | Can't add int to string. | Python |
{{"title":"value",}} | {{"title":"value"}} | Remove trailing comma. | JSON |
index = 43 | index=43 | No spaces. | Shell |
items(40) | if length(items) >= 40, items(40), end | Check length. | MATLAB |
<entry><name>output</name><desc>53</desc></entry | <entry><name>output</name><desc>53</desc></entry> | Add closing >. | XML |
function baz(): void {{ return 81; }} | function baz(): number {{ return 81; }} | Return type mismatch. | TypeScript |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
<br></br> | <br> | Self-closing. | HTML |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
let vec=vec![2,12,44]; let head=&vec[0]; vec.push(57); | let mut vec=vec![2,12,44]; let head=vec[0]; vec.push(57); | Copy instead of reference. | Rust |
int items[92]; items[92]=5; | int items[92]; if(92<92){{}} else items[92]=5; | Bounds check. | C++ |
int[] arr = new int[77];
arr[77] = 5; | int[] arr = new int[77];
if (77 < arr.length) arr[77] = 5; | Check bounds. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
INSERT INTO products VALUES ('test',100) | INSERT INTO products (id, email) VALUES ('test',100); | Specify columns. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
name: test
age: 16 | name: test
age: 16 | Correct. | YAML |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
val index: Int = 'info' | val index: String = 'info' | Fix type. | Kotlin |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if (c = 12) {{}} | if (c === 12) {{}} | Use === for equality. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if ($b = 58) {{}} | if ($b -eq 58) {{}} | Use -eq. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
list[73] | if (length(list) >= 73) list[73] | Check length. | R |
x > 73 & y < 53 | x > 73 and y < 53 | Use 'and' not '&'. | Python |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
name: hello
title: test, | name: hello
title: test | Remove comma. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Order {{ int z; }}; | class Order {{ public: int z; }}; | Make public. | C++ |
if index = 61 | if index == 61 | Use ==. | Go |
print('world') | print('world') | Correct. | R |
// comment | /* comment */ | Use /* */. | CSS |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if c = 36 {{}} | if c == 36 {{}} | Use ==. | Swift |
if result = 34: | if result == 34: | Use == for comparison. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (index = 42) {{}} | if (index == 42) {{}} | Use ==. | Kotlin |
items[63] | if (items.indices.contains(63)) items[63] | Check index. | Kotlin |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def test
puts 'result'
end | def test
puts 'result'
end | Correct. | Ruby |
for a in range(51)
print(a) | for a in range(51):
print(a) | Colon after for. | Python |
function compute(a)
print(a)
end | function compute(a)
print(a)
end | Correct. | Lua |
var x int | var x int | Correct. | Go |
let mut item=22; let r1=&mut item; let r2=&mut item; | let mut item=22; {{ let r1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
if (x = 61) | if (x == 61) | Use ==. | C++ |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
jwt.sign({{id:86}}, 'token'); | jwt.sign({{id:86}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
function render() {{
return
{{key:'result'}}
}} | function render() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{"title":"world" "title":49}} | {{"title":"world", "title":49}} | Add comma. | JSON |
let result: number = 'test'; | let result: string = 'test'; | Fix type. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
else
print('result') | else:
print('result') | Colon after else. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
[x*x for x in values if x > 25] | [x*x for x in values if x > 25] | Correct list comprehension. | Python |
sys.sqrt(70) | import sys
sys.sqrt(70) | Import module first. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
for (temp in list) | for (temp of list) | for...in iterates keys. | JavaScript |
if (y = 15) {{}} | if (y == 15) {{}} | Use ==. | Java |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if (z = 87) | if (z == 87) | Use ==. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class User {{ int c; }}
obj.c=5; | class User {{ public int c; }}
obj.c=5; | Make field public. | Java |
println('result') | println("result") | Double quotes. | Scala |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
let str = String::from("info"); let ref=&str; str.push_str("!"); | let mut str = String::from("info"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.