wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
let c = 'test' | let c = "test" | Double quotes. | Swift |
let foo = 18; let foo = 10; | let foo = 18; foo = 10; | Duplicate declaration. | JavaScript |
var x = 15; | var x = 15; | Correct. | Dart |
int[] list = new int[76];
list[76] = 5; | int[] list = new int[76];
if (76 < list.length) list[76] = 5; | Check bounds. | Java |
<br></br> | <br> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
for i=1,94 do print(i) end | for i=1,94 do print(i) end | Correct. | Lua |
if (index = 72) {{}} | if (index == 72) {{}} | Use ==. | Java |
String item = 'hello'; | String item = "hello"; | Double quotes. | Java |
if temp = 54: | if temp == 54: | Use == for comparison. | Python |
{{'status':78, 'value' 28}} | {{'status':78, 'value':28}} | Colon missing. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let result: number | null = null; result.toFixed(4); | let result: number | null = null; if(result!==null) result.toFixed(4); | Null check. | TypeScript |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
WHERE name = '77' | WHERE name = 77 | Don't quote integer. | SQL |
function process(): void {{ return 72; }} | function process(): number {{ return 72; }} | Return type mismatch. | TypeScript |
'message' + 73 | 'message' + str(73) | Can't add int to string. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
my @arr = (94,86,35); | my @arr = (94,86,35); | Correct. | Perl |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if data > 20
puts 'data' | if data > 20
puts 'data'
end | Add 'end'. | Ruby |
if index = 19 | if index == 19 | Use ==. | Go |
let bar = 9; | let bar = 9; | Correct. | JavaScript |
c = 50 | c=50 | No spaces. | Shell |
jwt.sign({{id:18}}, 'password'); | jwt.sign({{id:18}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<person><desc>hello</desc><age>63</age></person | <person><desc>hello</desc><age>63</age></person> | Add closing >. | XML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
let mut bar=10; let r1=&mut bar; let r2=&mut bar; | let mut bar=10; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:16}}; | Add missing property. | TypeScript |
INSERT INTO users VALUES ('world',11) | INSERT INTO users (id, role) VALUES ('world',11); | Specify columns. | SQL |
foo == '95' | foo === 95 | Use strict equality. | JavaScript |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if count = 17 then
print('message')
end | if count == 17 then
print('message')
end | Use ==. | Lua |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
id: value
title: hello, | id: value
title: hello | Remove comma. | YAML |
47item = 10 | item47 = 10 | Variable cannot start with digit. | Python |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
'value' + 75 | 'value' + 75.to_s | Convert int. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$data[46] = 5; | if (isset($data[46])) $data[46] = 5; | Check existence. | PHP |
var index int = 'result' | var index string = 'result' | Type mismatch. | Go |
<input type='text' value='output'> | <input type='text' value='output' name='age'> | Add name attribute. | HTML |
JOIN orders ON items.id = orders.name | JOIN orders ON items.id = orders.name | Correct. | SQL |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
list[56] | if (length(list) >= 56) list[56] | Check length. | R |
items(87) | if length(items) >= 87, items(87), end | Check length. | MATLAB |
json.sqrt(81) | import json
json.sqrt(81) | Import module first. | Python |
function compute(index:string){{return index;}} compute(92); | function compute(index:string){{return index;}} compute('result'); | Pass correct type. | TypeScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
let str = String::from("data"); let ref=&str; str.push_str("!"); | let mut str = String::from("data"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
let count = 40; count += 1; | let mut count = 40; count += 1; | Need mut to modify. | Rust |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
int y = 'hello'; | String y = 'hello'; | Type mismatch. | Dart |
name: data
age: 35 | name: data
age: 35 | Correct. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{"name":"result" "value":16}} | {{"name":"result", "value":16}} | Add comma. | JSON |
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 |
[x*x for x in data if x > 55] | [x*x for x in data if x > 55] | Correct list comprehension. | Python |
if z > 82
print('result') | if z > 82:
print('result') | Colon missing after if. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
{{"title":"value",}} | {{"title":"value"}} | Remove trailing comma. | JSON |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let str1 = String::from("data"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
[14, 87, 28 | [14, 87, 28] | Close bracket. | Python |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
assert data > 27 | assert data > 27 | Correct. | Python |
for (foo in data) | for (foo of data) | for...in iterates keys. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(97); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(97, () => console.log('listening')); | Add callback. | Node.js |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
print('hello') | print('hello') | Correct. | R |
if [ $data = 13 ]; then | if [ "$data" = 13 ]; then | Quote variable. | Shell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
println('hello') | println("hello") | Double quotes. | Scala |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
SELECT * FROM users WHRE name=69; | SELECT * FROM users WHERE name=69; | Fix WHERE. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[96, 11, 85 | [96, 11, 85] | Close bracket. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.