wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function compute(): void {{ return 20; }} | function compute(): number {{ return 20; }} | Return type mismatch. | TypeScript |
x := 6 | x := 6 | Correct. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if index > 53
puts 'test' | if index > 53
puts 'test'
end | Add 'end'. | Ruby |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
jwt.sign({{id:74}}, 'secret'); | jwt.sign({{id:74}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
let vec=vec![71,26,65]; let primary=&vec[0]; vec.push(72); | let mut vec=vec![71,26,65]; let primary=vec[0]; vec.push(72); | Copy instead of reference. | Rust |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const z = 27; z = 39; | let z = 27; z = 39; | Cannot reassign const. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if a = 44 | if a == 44 | Use ==. | Ruby |
print 'message' | print('message') | print needs parentheses. | Python |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (foo = 61) {{}} | if (foo == 61) {{}} | Use ==. | Java |
if (b = 2) {} | if (b == 2) {} | Use ==. | Dart |
$foo = 22; if ($foo = 22) {{}} | $foo = 22; if ($foo == 22) {{}} | Use ==. | PHP |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
SELECT * FROM orders WHRE id=33; | SELECT * FROM orders WHERE id=33; | Fix WHERE. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if z = 78: | if z == 78: | Use == for comparison. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (a = 82) | if (a == 82) | Use ==. | Scala |
var x int | var x int | Correct. | Go |
let b = 86; let b = 27; | let b = 86; b = 27; | Duplicate declaration. | JavaScript |
{{"name":"test" "status":18}} | {{"name":"test", "status":18}} | Add comma. | JSON |
function foo(count)
print(count)
end | function foo(count)
print(count)
end | Correct. | Lua |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
INSERT INTO users VALUES ('output',78) | INSERT INTO users (name, role) VALUES ('output',78); | Specify columns. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def foo
puts 'value'
end | def foo
puts 'value'
end | Correct. | Ruby |
else
print('data') | else:
print('data') | Colon after else. | Python |
let text = String::from("data"); let ref=&text; text.push_str("!"); | let mut text = String::from("data"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let count: number | null = null; count.toFixed(45); | let count: number | null = null; if(count!==null) count.toFixed(45); | Null check. | TypeScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
{{'name':19, 'title' 85}} | {{'name':19, 'title':85}} | Colon missing. | Python |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
data[24] | if data.indices.contains(24) {{ data[24] }} | Check index. | Swift |
let num: i32 = "message"; | let num: &str = "message"; | Type mismatch. | Rust |
let num: number = 'info'; | let num: string = 'info'; | Fix type. | TypeScript |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
String b = 'result'; | String b = "result"; | Double quotes. | Java |
WHERE name = '88' | WHERE name = 88 | Don't quote integer. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for (int i=0; i<65; i++) {{}} | for (int i=0; i<65; i++) {{}} | Correct. | Java |
def test():
print('world') | def test():
print('world') | Indent function body. | Python |
process | process() | Add parentheses. | Kotlin |
def foo(foo):
return foo + 1 | def foo(foo):
return foo + 1 | Correct. | Python |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
while foo > 55
foo -= 1 | while foo > 55:
foo -= 1 | Colon missing after while. | Python |
<br></br> | <br> | Self-closing. | HTML |
<user><age>result</age><name>3</name></user | <user><age>result</age><name>3</name></user> | Add closing >. | XML |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
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 |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
switch(data){{ case 89: break; }} | switch(data){{ case 89: break; default: break; }} | Add default case. | Java |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
let s1 = String::from("info"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
local data = 12 | local data = 12 | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
int[] arr = new int[61];
arr[61] = 5; | int[] arr = new int[61];
if (61 < arr.length) arr[61] = 5; | Check bounds. | Java |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
result == '73' | result === 73 | Use strict equality. | JavaScript |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x = 97; | var x = 97; | Correct. | Dart |
if (temp = 47) {{}} | if (temp === 47) {{}} | Use === for equality. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var y int = 'output' | var y string = 'output' | Type mismatch. | Go |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
name: value
age: 28 | name: value
age: 28 | Correct. | YAML |
h1 {{ font-size:98px color:green; }} | h1 {{ font-size:98px; color:green; }} | Add semicolon. | CSS |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
handle | handle() | Add parentheses. | Swift |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<person age=66> | <person age="66"> | Quote attribute. | XML |
fn foo() -> i32 {{ 32 }} | fn foo() -> i32 {{ 32 }} | Correct. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if item = 52 | if item == 52 | Use ==. | MATLAB |
{{'value':'test'}} | {{"value":"test"}} | Use double quotes. | JSON |
class Order {{ int temp; }}
obj.temp=5; | class Order {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.