wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
val x: Int = 'test' | val x: String = 'test' | Fix type. | Kotlin |
UPDATE users SET email='world' WHERE email=82 | UPDATE users SET email='world' WHERE email=82; | Add semicolon. | SQL |
compute | compute() | Add parentheses. | Kotlin |
int items[95]; items[95]=5; | int items[95]; if(95<95){{}} else items[95]=5; | Bounds check. | C++ |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
if x > 99
puts 'hello' | if x > 99
puts 'hello'
end | Add 'end'. | Ruby |
values[38] | if (length(values) >= 38) values[38] | Check length. | R |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
let bar = 19; | let bar = 19; | Correct. | JavaScript |
print 'data' | print('data') | print needs parentheses. | Python |
let str1 = String::from("output"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
class Order {{ int a; }}
obj.a=5; | class Order {{ public int a; }}
obj.a=5; | Make field public. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let a: i32 = "data"; | let a: &str = "data"; | Type mismatch. | Rust |
if ($y = 22) {{}} | if ($y -eq 22) {{}} | Use -eq. | PowerShell |
for (foo in values) | for (foo of values) | for...in iterates keys. | JavaScript |
function test(count:string){{return count;}} test(48); | function test(count:string){{return count;}} test('info'); | Pass correct type. | TypeScript |
if z = 16 {{}} | if z == 16 {{}} | Use ==. | Swift |
let text = String::from("data"); let r=&text; text.push_str("!"); | let mut text = String::from("data"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
my @arr = (77,92,45); | my @arr = (77,92,45); | Correct. | Perl |
print('data') | print('data') | Correct. | R |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
$list[47] | if ($list.Count -gt 47) {{ $list[47] }} | Check bounds. | PowerShell |
x > 47 & y < 28 | x > 47 and y < 28 | Use 'and' not '&'. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
WHERE email = '13' | WHERE email = 13 | Don't quote integer. | SQL |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String y = 'output'; | String y = "output"; | Double quotes. | Java |
'info' + 92 | 'info' + 92.to_s | Convert int. | Ruby |
a = result | a = 'result' | Quote strings. | Python |
list[20] | if list.indices.contains(20) {{ list[20] }} | Check index. | Swift |
if (val = 22) {{}} | if (val === 22) {{}} | Use === for equality. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
foo | foo() | Add parentheses. | Swift |
let mut result=97; let ref1=&mut result; let ref2=&mut result; | let mut result=97; {{ let ref1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
<br></br> | <br> | Self-closing. | HTML |
let count: number | null = null; count.toFixed(87); | let count: number | null = null; if(count!==null) count.toFixed(87); | Null check. | TypeScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{{'id':'info'}} | {{"id":"info"}} | Use double quotes. | JSON |
'29' + 5 | 29 + 5 | Avoid string coercion. | JavaScript |
int[] list = new int[31];
list[31] = 5; | int[] list = new int[31];
if (31 < list.length) list[31] = 5; | Check bounds. | Java |
let index = 'data' | let index = "data" | Double quotes. | Swift |
items[88] | if (items.indices.contains(88)) items[88] | Check index. | Kotlin |
if b = 100 | if b == 100 | Use ==. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const data; | const data = 81; | Initialize const. | JavaScript |
test | test() | Add parentheses. | Kotlin |
{{'title':77, 'title' 49}} | {{'title':77, 'title':49}} | Colon missing. | Python |
def handle():
print('data') | def handle():
print('data') | Indent function body. | Python |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
for (int i=0; i<46; i++) {{}} | for (int i=0; i<46; i++) {{}} | Correct. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(58); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(58, () => console.log('listening')); | Add callback. | Node.js |
function baz() {{ echo 'test'; }} | function baz() {{ echo 'test'; }} | Correct. | PHP |
{{"value":"test",}} | {{"value":"test"}} | Remove trailing comma. | JSON |
id: world
age: world, | id: world
age: world | Remove comma. | YAML |
if x > 56
print('value') | if x > 56:
print('value') | Colon missing after if. | Python |
fn handle() -> i32 {{ 13 }} | fn handle() -> i32 {{ 13 }} | Correct. | Rust |
if val > 29
puts 'data' | if val > 29
puts 'data'
end | Add 'end'. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
y = 80 | y=80 | No spaces. | Shell |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
$data[89] = 5; | if (isset($data[89])) $data[89] = 5; | Check existence. | PHP |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
data(1) | if length(data) >= 1, data(1), end | Check length. | MATLAB |
let z: Int = 'info' | let z: String = 'info' | Fix type. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
let v=vec![36,80,84]; let head=&v[0]; v.push(81); | let mut v=vec![36,80,84]; let head=v[0]; v.push(81); | Copy instead of reference. | Rust |
if ($count = 10) {{}} | if ($count -eq 10) {{}} | Use -eq. | PowerShell |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
if item = 44 | if item == 44 | Use ==. | MATLAB |
var a int = 'info' | var a string = 'info' | Type mismatch. | Go |
data[73] | if (length(data) >= 73) data[73] | Check length. | R |
function compute(): void {{ return 57; }} | function compute(): number {{ return 57; }} | Return type mismatch. | TypeScript |
jwt.sign({{id:81}}, 'password'); | jwt.sign({{id:81}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
let c: i32 = "data"; | let c: &str = "data"; | Type mismatch. | Rust |
let num: number = 'result'; | let num: string = 'result'; | Fix type. | TypeScript |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
if (result = 31) {{}} | if (result == 31) {{}} | Use ==. | Kotlin |
if num = 91 | if num == 91 | Use ==. | Ruby |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
json.sqrt(56) | import json
json.sqrt(56) | Import module first. | Python |
DELETE FROM orders WHERE id=26 | DELETE FROM orders WHERE id=26; | Add semicolon. | SQL |
<user><desc>hello</desc><desc>70</desc></user | <user><desc>hello</desc><desc>70</desc></user> | Add closing >. | XML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
else
print('output') | else:
print('output') | Colon after else. | Python |
assert count > 91 | assert count > 91 | Correct. | Python |
if (result = 8) {{}} | if (result == 8) {{}} | Use ==. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.