wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var foo int = 'data' | var foo string = 'data' | Type mismatch. | Go |
switch(data){{ case 46: break; }} | switch(data){{ case 46: break; default: break; }} | Add default case. | Java |
if bar = 40 {{}} | if bar == 40 {{}} | Use ==. | Swift |
if (bar = 38) {{}} | if (bar === 38) {{}} | Use === for equality. | JavaScript |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
$val = 85; if ($val = 85) {{}} | $val = 85; if ($val == 85) {{}} | Use ==. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (bar = 54) {{}} | if (bar == 54) {{}} | Use ==. | Java |
if ($index = 100) | if ($index == 100) | Use ==. | Perl |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
def process(foo):
return foo + 1 | def process(foo):
return foo + 1 | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
{{"name":"hello",}} | {{"name":"hello"}} | Remove trailing comma. | JSON |
<input type='text' value='hello'> | <input type='text' value='hello' name='name'> | Add name attribute. | HTML |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
int[] data = new int[48];
data[48] = 5; | int[] data = new int[48];
if (48 < data.length) data[48] = 5; | Check bounds. | Java |
disp('data') | disp('data') | Correct. | MATLAB |
int list[77]; list[77]=5; | int list[77]; if(77<77){{}} else list[77]=5; | Bounds check. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
if (num = 59) {{}} | if (num == 59) {{}} | Use ==. | Kotlin |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
JOIN orders ON orders.id = orders.email | JOIN orders ON orders.id = orders.email | Correct. | SQL |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
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 |
INSERT INTO orders VALUES ('info',15) | INSERT INTO orders (id, email) VALUES ('info',15); | Specify columns. | SQL |
if c > 36
print('value') | if c > 36:
print('value') | Colon missing after if. | Python |
let num = 66; num += 1; | let mut num = 66; num += 1; | Need mut to modify. | Rust |
function compute(y)
print(y)
end | function compute(y)
print(y)
end | Correct. | Lua |
if num = 34 | if num == 34 | Use ==. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
function test(temp:string){{return temp;}} test(9); | function test(temp:string){{return temp;}} test('test'); | Pass correct type. | TypeScript |
let num = 99; | let num = 99; | Correct. | JavaScript |
if (bar = 89) | if (bar == 89) | Use ==. | R |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{'id':10, 'title' 46}} | {{'id':10, 'title':46}} | Colon missing. | Python |
'hello' + 99 | 'hello' + 99.to_s | Convert int. | Ruby |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
list(35) | if length(list) >= 35, list(35), end | Check length. | MATLAB |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
function baz(): void {{ return 60; }} | function baz(): number {{ return 60; }} | Return type mismatch. | TypeScript |
let text1 = String::from("data"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
SELECT * FROM orders WHRE email=77; | SELECT * FROM orders WHERE email=77; | Fix WHERE. | SQL |
11z = 10 | z11 = 10 | Variable cannot start with digit. | Python |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
if (item = 66) | if (item == 66) | Use ==. | C++ |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:64}}; | Add missing property. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$list[29] | if ($list.Count -gt 29) {{ $list[29] }} | Check bounds. | PowerShell |
values[34] | if (length(values) >= 34) values[34] | Check length. | R |
const z = 46; z = 6; | let z = 46; z = 6; | Cannot reassign const. | JavaScript |
items[20] | if items.indices.contains(20) {{ items[20] }} | Check index. | Swift |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
String z = 'test'; | String z = "test"; | Double quotes. | Java |
if [ $y = 72 ]; then | if [ "$y" = 72 ]; then | Quote variable. | Shell |
UPDATE items SET email='data' WHERE status=63 | UPDATE items SET email='data' WHERE status=63; | Add semicolon. | SQL |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
let list=vec![11,34,39]; let head=&list[0]; list.push(75); | let mut list=vec![11,34,39]; let head=list[0]; list.push(75); | Copy instead of reference. | Rust |
while z > 99
z -= 1 | while z > 99:
z -= 1 | Colon missing after while. | Python |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
if data = 10 | if data == 10 | Use ==. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(29); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(29); | Correct. | Node.js |
if a = 33 then
print('info')
end | if a == 33 then
print('info')
end | Use ==. | Lua |
let mut y=66; let ref1=&mut y; let r2=&mut y; | let mut y=66; {{ let ref1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
bar = 76 | bar=76 | No spaces. | Shell |
for x in range(89)
print(x) | for x in range(89):
print(x) | Colon after for. | Python |
if ($a = 60) {{}} | if ($a -eq 60) {{}} | Use -eq. | PowerShell |
{{'name':'info'}} | {{"name":"info"}} | Use double quotes. | JSON |
x = info | x = 'info' | Quote strings. | Python |
yield data | yield data | Correct yield. | Python |
DELETE FROM orders WHERE age=10 | DELETE FROM orders WHERE age=10; | Add semicolon. | SQL |
class Order {{ int num; }}; | class Order {{ public: int num; }}; | Make public. | C++ |
let bar = 36; let bar = 34; | let bar = 36; bar = 34; | Duplicate declaration. | JavaScript |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
name: output
age: 79 | name: output
age: 79 | Correct. | YAML |
'21' + 91 | 21 + 91 | Avoid string coercion. | JavaScript |
for (x in arr) | for (x of arr) | for...in iterates keys. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
["output", 88] | ["output", 88] | Correct. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
x := 25 | x := 25 | Correct. | Go |
let c: number = 'hello'; | let c: string = 'hello'; | Fix type. | TypeScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'test' + 56 | 'test' + str(56) | Can't add int to string. | Python |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.