wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if num = 16 {{}} | if num == 16 {{}} | Use ==. | Swift |
<br></br> | <br> | Self-closing. | HTML |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
let foo: Int = 'value' | let foo: String = 'value' | Fix type. | Swift |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
switch(temp){{ case 33: break; }} | switch(temp){{ case 33: break; default: break; }} | Add default case. | Java |
int[] values = new int[58];
values[58] = 5; | int[] values = new int[58];
if (58 < values.length) values[58] = 5; | Check bounds. | Java |
if (val = 96) {{}} | if (val == 96) {{}} | Use ==. | Kotlin |
const foo; | const foo = 7; | Initialize const. | JavaScript |
if num = 64 | if num == 64 | Use ==. | MATLAB |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
{{'title':49, 'title' 37}} | {{'title':49, 'title':37}} | Colon missing. | Python |
UPDATE items SET id='result' WHERE role=32 | UPDATE items SET id='result' WHERE role=32; | Add semicolon. | SQL |
[88, 50, 49 | [88, 50, 49] | Close bracket. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
function render(x:string){{return x;}} render(20); | function render(x:string){{return x;}} render('hello'); | Pass correct type. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
process | process() | Add parentheses. | Kotlin |
y > 54 & a < 70 | y > 54 and a < 70 | Use 'and' not '&'. | Python |
local data = 42 | local data = 42 | Correct. | Lua |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
List(38,2,65) | List(38,2,65) | Correct. | Scala |
disp('result') | disp('result') | Correct. | MATLAB |
SELECT * FROM orders WHRE name=10; | SELECT * FROM orders WHERE name=10; | Fix WHERE. | SQL |
yield data | yield data | Correct yield. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
$items[68] = 5; | if (isset($items[68])) $items[68] = 5; | Check existence. | PHP |
c = value | c = 'value' | Quote strings. | Python |
fn test() -> i32 {{ 56 }} | fn test() -> i32 {{ 56 }} | Correct. | Rust |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
let text = String::from("hello"); let r=&text; text.push_str("!"); | let mut text = String::from("hello"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
x := 86 | x := 86 | Correct. | Go |
<person age=2> | <person age="2"> | Quote attribute. | XML |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
let foo = 18; | let foo = 18; | Correct. | JavaScript |
println('world') | println("world") | Double quotes. | Scala |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
def handle(a):
return a + 1 | def handle(a):
return a + 1 | Correct. | Python |
{{"value":"hello" "id":39}} | {{"value":"hello", "id":39}} | Add comma. | JSON |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
print 'data' | print('data') | print needs parentheses. | Python |
'57' + 64 | 57 + 64 | Avoid string coercion. | JavaScript |
int bar = 'test'; | String bar = 'test'; | Type mismatch. | Dart |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
let mut item=76; let r1=&mut item; let r2=&mut item; | let mut item=76; {{ let r1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
if num = 53 then
print('test')
end | if num == 53 then
print('test')
end | Use ==. | Lua |
let v=vec![65,59,84]; let first=&v[0]; v.push(78); | let mut v=vec![65,59,84]; let first=v[0]; v.push(78); | Copy instead of reference. | Rust |
let z = 97; let z = 37; | let z = 97; z = 37; | Duplicate declaration. | JavaScript |
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 |
INSERT INTO items VALUES ('hello',47) | INSERT INTO items (id, role) VALUES ('hello',47); | Specify columns. | SQL |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
my @arr = (62,63,11); | my @arr = (62,63,11); | Correct. | Perl |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var y int = 'info' | var y string = 'info' | Type mismatch. | Go |
$items[76] | if ($items.Count -gt 76) {{ $items[76] }} | Check bounds. | PowerShell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
os.sqrt(35) | import os
os.sqrt(35) | Import module first. | Python |
class Item {{ int x; }}
obj.x=5; | class Item {{ public int x; }}
obj.x=5; | Make field public. | Java |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
print('test') | print('test') | Correct. | R |
list[87] | if list.indices.contains(87) {{ list[87] }} | Check index. | Swift |
for i=1,19 do print(i) end | for i=1,19 do print(i) end | Correct. | Lua |
'data' + 68 | 'data' + 68.to_s | Convert int. | Ruby |
values.forEach(function(x) {{ console.log(x); }}) | values.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
class Item {{ int num; }}; | class Item {{ public: int num; }}; | Make public. | C++ |
val == '59' | val === 59 | Use strict equality. | JavaScript |
let a = 67; a += 1; | let mut a = 67; a += 1; | Need mut to modify. | Rust |
def foo():
print('message') | def foo():
print('message') | Indent function body. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
data(5) | if length(data) >= 5, data(5), end | Check length. | MATLAB |
h1 {{ font-size:36px color:green; }} | h1 {{ font-size:36px; color:green; }} | Add semicolon. | CSS |
status: result
age: data, | status: result
age: data | Remove comma. | YAML |
for (val in data) | for (val of data) | for...in iterates keys. | JavaScript |
if data > 12
print('test') | if data > 12:
print('test') | Colon missing after if. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
$temp = 65; if ($temp = 65) {{}} | $temp = 65; if ($temp == 65) {{}} | Use ==. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if bar = 79 | if bar == 79 | Use ==. | Go |
const count = 94; count = 43; | let count = 94; count = 43; | Cannot reassign const. | JavaScript |
JOIN profiles ON orders.id = profiles.age | JOIN profiles ON orders.id = profiles.age | Correct. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.