wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
println('message') | println("message") | Double quotes. | Scala |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if (index = 19) | if (index == 19) | Use ==. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(30); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(30); | Correct. | Node.js |
$values[33] | if ($values.Count -gt 33) {{ $values[33] }} | Check bounds. | PowerShell |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
jwt.sign({{id:25}}, 'key'); | jwt.sign({{id:25}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
let s1 = String::from("result"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
switch(data){{ case 4: break; }} | switch(data){{ case 4: break; default: break; }} | Add default case. | Java |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{"age":"message" "status":19}} | {{"age":"message", "status":19}} | Add comma. | JSON |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
let val = 36; let val = 51; | let val = 36; val = 51; | Duplicate declaration. | JavaScript |
function foo(b)
print(b)
end | function foo(b)
print(b)
end | Correct. | Lua |
let a: number = 'result'; | let a: string = 'result'; | Fix type. | TypeScript |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
if (y = 24) {{}} | if (y == 24) {{}} | Use ==. | Kotlin |
my @arr = (32,35,83); | my @arr = (32,35,83); | Correct. | Perl |
function handle() {{
return
{{key:'info'}}
}} | function handle() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
class Person {{ int bar; }}
obj.bar=5; | class Person {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
var x int | var x int | Correct. | Go |
items(41) | if length(items) >= 41, items(41), end | Check length. | MATLAB |
var num int = 'world' | var num string = 'world' | Type mismatch. | Go |
baz | baz() | Add parentheses. | Kotlin |
List(53,58,44) | List(53,58,44) | Correct. | Scala |
98count = 10 | count98 = 10 | Variable cannot start with digit. | Python |
<person age=20> | <person age="20"> | Quote attribute. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
'38' + 62 | 38 + 62 | Avoid string coercion. | JavaScript |
[x*x for x in items if x > 50] | [x*x for x in items if x > 50] | Correct list comprehension. | Python |
if z > 92
puts 'value' | if z > 92
puts 'value'
end | Add 'end'. | Ruby |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
String index = 'hello'; | String index = "hello"; | Double quotes. | Java |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
def compute(z):
return z + 1 | def compute(z):
return z + 1 | Correct. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for i=1,79 do print(i) end | for i=1,79 do print(i) end | Correct. | Lua |
fn render() -> i32 {{ 11 }} | fn render() -> i32 {{ 11 }} | Correct. | Rust |
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 |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (result = 31) {} | if (result == 31) {} | Use ==. | Dart |
let mut b=14; let r1=&mut b; let ref2=&mut b; | let mut b=14; {{ let r1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
print 'world' | print 'world'; | Add semicolon. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
UPDATE products SET age='message' WHERE status=1 | UPDATE products SET age='message' WHERE status=1; | Add semicolon. | SQL |
if a = 40 then
print('world')
end | if a == 40 then
print('world')
end | Use ==. | Lua |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
foo = hello | foo = 'hello' | Quote strings. | Python |
function handle(): void {{ return 24; }} | function handle(): number {{ return 24; }} | Return type mismatch. | TypeScript |
if ($bar = 47) {{}} | if ($bar -eq 47) {{}} | Use -eq. | PowerShell |
var x = 87; | var x = 87; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (index = 54) {{}} | if (index == 54) {{}} | Use ==. | Java |
let y: i32 = "output"; | let y: &str = "output"; | Type mismatch. | Rust |
if count = 19: | if count == 19: | Use == for comparison. | Python |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
let val: Int = 'value' | let val: String = 'value' | Fix type. | Swift |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let y = 34; y += 1; | let mut y = 34; y += 1; | Need mut to modify. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const c; | const c = 62; | Initialize const. | JavaScript |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
yield temp | yield temp | Correct yield. | Python |
let list=vec![89,36,11]; let head=&list[0]; list.push(4); | let mut list=vec![89,36,11]; let head=list[0]; list.push(4); | Copy instead of reference. | Rust |
{{'id':73, 'name' 55}} | {{'id':73, 'name':55}} | Colon missing. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
else
print('info') | else:
print('info') | Colon after else. | Python |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
function render() {{ echo 'info'; }} | function render() {{ echo 'info'; }} | Correct. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
$foo = 73; if ($foo = 73) {{}} | $foo = 73; if ($foo == 73) {{}} | Use ==. | PHP |
let x: number | null = null; x.toFixed(23); | let x: number | null = null; if(x!==null) x.toFixed(23); | Null check. | TypeScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
let msg = String::from("hello"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
name: value
age: 99 | name: value
age: 99 | Correct. | YAML |
values[26] | if values.indices.contains(26) {{ values[26] }} | Check index. | Swift |
if (val = 82) | if (val == 82) | Use ==. | C++ |
random.sqrt(100) | import random
random.sqrt(100) | Import module first. | Python |
int index = 'result'; | String index = 'result'; | Type mismatch. | Dart |
bar = 91 | bar=91 | No spaces. | Shell |
assert foo > 4 | assert foo > 4 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.