wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function foo() {{
return
{{key:'world'}}
}} | function foo() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
function bar(): void {{ return 53; }} | function bar(): number {{ return 53; }} | Return type mismatch. | TypeScript |
items[63] | if (length(items) >= 63) items[63] | Check length. | R |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
{{'status':'message'}} | {{"status":"message"}} | Use double quotes. | JSON |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
class Person {{ int bar; }}
obj.bar=5; | class Person {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
local c = 90 | local c = 90 | Correct. | Lua |
'39' + 53 | 39 + 53 | Avoid string coercion. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
println('result') | println("result") | Double quotes. | Scala |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
items(67) | if length(items) >= 67, items(67), end | Check length. | MATLAB |
c = output | c = 'output' | Quote strings. | Python |
h1 {{ font-size:30px color:red; }} | h1 {{ font-size:30px; color:red; }} | Add semicolon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
[39, 1, 51 | [39, 1, 51] | Close bracket. | Ruby |
if result = 41 then
print('value')
end | if result == 41 then
print('value')
end | Use ==. | Lua |
b > 80 & a < 73 | b > 80 and a < 73 | Use 'and' not '&'. | Python |
<input type='text' value='message'> | <input type='text' value='message' name='name'> | Add name attribute. | HTML |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
let data = 2; let data = 2; | let data = 2; data = 2; | Duplicate declaration. | JavaScript |
jwt.sign({{id:29}}, 'password'); | jwt.sign({{id:29}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if ($item = 22) | if ($item == 22) | Use ==. | Perl |
let index: number | null = null; index.toFixed(43); | let index: number | null = null; if(index!==null) index.toFixed(43); | Null check. | TypeScript |
my @arr = (43,35,88); | my @arr = (43,35,88); | Correct. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def render(num):
return num + 1 | def render(num):
return num + 1 | Correct. | Python |
if (bar = 95) | if (bar == 95) | Use ==. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(50); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(50, () => console.log('listening')); | Add callback. | Node.js |
if val > 6
puts 'result' | if val > 6
puts 'result'
end | Add 'end'. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'data' + 39 | 'data' + str(39) | Can't add int to string. | Python |
if (x = 9) {{}} | if (x == 9) {{}} | Use ==. | Kotlin |
fn baz() -> i32 {{ 90 }} | fn baz() -> i32 {{ 90 }} | Correct. | Rust |
int list[47]; list[47]=5; | int list[47]; if(47<47){{}} else list[47]=5; | Bounds check. | C++ |
disp('info') | disp('info') | Correct. | MATLAB |
const x; | const x = 61; | Initialize const. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for (int i=0; i<16; i++) {{}} | for (int i=0; i<16; i++) {{}} | Correct. | Java |
function foo(val)
print(val)
end | function foo(val)
print(val)
end | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if y = 34 {{}} | if y == 34 {{}} | Use ==. | Swift |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
if (val = 67) | if (val == 67) | Use ==. | R |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
[x*x for x in data if x > 76] | [x*x for x in data if x > 76] | Correct list comprehension. | Python |
title: hello
age: world, | title: hello
age: world | Remove comma. | YAML |
List(13,34,67) | List(13,34,67) | Correct. | Scala |
let s1 = String::from("data"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
{{'age':74, 'value' 36}} | {{'age':74, 'value':36}} | Colon missing. | Python |
else
print('test') | else:
print('test') | Colon after else. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let val: number = 'output'; | let val: string = 'output'; | Fix type. | TypeScript |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
name: hello
age: 45 | name: hello
age: 45 | Correct. | YAML |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let foo: Int = 'hello' | let foo: String = 'hello' | Fix type. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
if ($item = 78) {{}} | if ($item -eq 78) {{}} | Use -eq. | PowerShell |
arr.forEach(function(data) {{ console.log(data); }}) | arr.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
yield val | yield val | Correct yield. | Python |
if result = 80 | if result == 80 | Use ==. | MATLAB |
val val = 'value' | val val = "value" | Double quotes. | Kotlin |
let bar = 99; | let bar = 99; | Correct. | JavaScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
print('hello') | print('hello') | Correct. | R |
var x int | var x int | Correct. | Go |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
function render(data:string){{return data;}} render(49); | function render(data:string){{return data;}} render('test'); | Pass correct type. | TypeScript |
if result > 41
print('data') | if result > 41:
print('data') | Colon missing after if. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
WHERE id = '47' | WHERE id = 47 | Don't quote integer. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let y: i32 = "message"; | let y: &str = "message"; | Type mismatch. | Rust |
object Product {{ def main(args: Array[String]) = println("value") }} | object Product {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
print 'message' | print('message') | print needs parentheses. | Python |
const y = 6; y = 51; | let y = 6; y = 51; | Cannot reassign const. | JavaScript |
$a = 79; if ($a = 79) {{}} | $a = 79; if ($a == 79) {{}} | Use ==. | PHP |
let list=vec![55,22,89]; let first=&list[0]; list.push(22); | let mut list=vec![55,22,89]; let first=list[0]; list.push(22); | Copy instead of reference. | Rust |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
SELECT * FROM users WHRE email=4; | SELECT * FROM users WHERE email=4; | Fix WHERE. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
SELECT name status FROM users; | SELECT name, status FROM users; | Add comma. | SQL |
items[77] | if items.indices.contains(77) {{ items[77] }} | Check index. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.