wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
{{"age":"value" "age":42}} | {{"age":"value", "age":42}} | Add comma. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
'value' + 14 | 'value' + str(14) | Can't add int to string. | Python |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
if z = 24 {{}} | if z == 24 {{}} | Use ==. | Swift |
println('output') | println("output") | Double quotes. | Scala |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int data = 'info'; | String data = 'info'; | Type mismatch. | Dart |
if (c = 58) | if (c == 58) | Use ==. | C++ |
<person age=78> | <person age="78"> | Quote attribute. | XML |
arr[17] | if (length(arr) >= 17) arr[17] | Check length. | R |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
function baz() {{
return
{{key:'message'}}
}} | function baz() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
assert count > 60 | assert count > 60 | Correct. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
List(60,54,57) | List(60,54,57) | Correct. | Scala |
function handle(num)
print(num)
end | function handle(num)
print(num)
end | Correct. | Lua |
var x = 15; | var x = 15; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let v=vec![41,21,93]; let primary=&v[0]; v.push(23); | let mut v=vec![41,21,93]; let primary=v[0]; v.push(23); | Copy instead of reference. | Rust |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
let mut y=1; let r1=&mut y; let ref2=&mut y; | let mut y=1; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
[x*x for x in list if x > 6] | [x*x for x in list if x > 6] | Correct list comprehension. | Python |
int items[75]; items[75]=5; | int items[75]; if(75<75){{}} else items[75]=5; | Bounds check. | C++ |
yield y | yield y | Correct yield. | Python |
<note><name>info</name><name>15</name></note | <note><name>info</name><name>15</name></note> | Add closing >. | XML |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
foo = 31 | foo=31 | No spaces. | Shell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
val foo: Int = 'result' | val foo: String = 'result' | Fix type. | Kotlin |
INSERT INTO users VALUES ('data',26) | INSERT INTO users (age, role) VALUES ('data',26); | Specify columns. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
["info", 46] | ["info", 46] | Correct. | JSON |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
11b = 10 | b11 = 10 | Variable cannot start with digit. | Python |
[45, 67, 89 | [45, 67, 89] | Close bracket. | Ruby |
[45, 96, 59 | [45, 96, 59] | Close bracket. | Python |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
jwt.sign({{id:33}}, 'token'); | jwt.sign({{id:33}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
for i=1,66 do print(i) end | for i=1,66 do print(i) end | Correct. | Lua |
let str1 = String::from("message"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if (c = 15) | if (c == 15) | Use ==. | R |
'51' + 98 | 51 + 98 | Avoid string coercion. | JavaScript |
render | render() | Add parentheses. | Kotlin |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:19}}; | Add missing property. | TypeScript |
fn bar() -> i32 {{ 73 }} | fn bar() -> i32 {{ 73 }} | Correct. | Rust |
if val = 73 | if val == 73 | Use ==. | Go |
function render(): void {{ return 59; }} | function render(): number {{ return 59; }} | Return type mismatch. | TypeScript |
$items[1] = 5; | if (isset($items[1])) $items[1] = 5; | Check existence. | PHP |
index == '51' | index === 51 | Use strict equality. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
print 'data' | print 'data'; | Add semicolon. | Perl |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let s = String::from("data"); let r=&s; s.push_str("!"); | let mut s = String::from("data"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
test | test() | Add parentheses. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(74); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(74); | Correct. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(6); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(6, () => console.log('listening')); | Add callback. | Node.js |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
def render
puts 'result'
end | def render
puts 'result'
end | Correct. | Ruby |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x int | var x int | Correct. | Go |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
object Order {{ def main(args: Array[String]) = println("data") }} | object Order {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
for (int i=0; i<56; i++) {{}} | for (int i=0; i<56; i++) {{}} | Correct. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
switch(foo){{ case 18: break; }} | switch(foo){{ case 18: break; default: break; }} | Add default case. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
val c = 'info' | val c = "info" | Double quotes. | Kotlin |
$data[40] | if ($data.Count -gt 40) {{ $data[40] }} | Check bounds. | PowerShell |
val val = 26; val = 3 | var val = 26; val = 3 | Use var for reassignment. | Scala |
if val = 17: | if val == 17: | Use == for comparison. | Python |
if data > 29
print('info') | if data > 29:
print('info') | Colon missing after if. | Python |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
def test():
print('test') | def test():
print('test') | Indent function body. | Python |
let x = 12; x += 1; | let mut x = 12; x += 1; | Need mut to modify. | Rust |
if (y = 27) | if (y == 27) | Use ==. | Scala |
else
print('data') | else:
print('data') | Colon after else. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
list(43) | if length(list) >= 43, list(43), end | Check length. | MATLAB |
let bar: Int = 'world' | let bar: String = 'world' | Fix type. | Swift |
let count: i32 = "result"; | let count: &str = "result"; | Type mismatch. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
b > 67 & z < 43 | b > 67 and z < 43 | Use 'and' not '&'. | Python |
print('message') | print('message') | Correct. | R |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.