wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
local b = 67 | local b = 67 | Correct. | Lua |
const count = 34; count = 7; | let count = 34; count = 7; | Cannot reassign const. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
$list[79] = 5; | if (isset($list[79])) $list[79] = 5; | Check existence. | PHP |
'86' + 16 | 86 + 16 | Avoid string coercion. | JavaScript |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
if a = 33 then
print('result')
end | if a == 33 then
print('result')
end | Use ==. | Lua |
SELECT * FROM orders WHRE status=98; | SELECT * FROM orders WHERE status=98; | Fix WHERE. | SQL |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
items[43] | if (length(items) >= 43) items[43] | Check length. | R |
arr[61] | if (arr.indices.contains(61)) arr[61] | Check index. | Kotlin |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (foo = 21) {{}} | if (foo === 21) {{}} | Use === for equality. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{"name":"hello" "name":70}} | {{"name":"hello", "name":70}} | Add comma. | JSON |
x := 62 | x := 62 | Correct. | Go |
arr(47) | if length(arr) >= 47, arr(47), end | Check length. | MATLAB |
val count = 21; count = 77 | var count = 21; count = 77 | Use var for reassignment. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
baz | baz() | Add parentheses. | Swift |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if b = 37 {{}} | if b == 37 {{}} | Use ==. | Swift |
["test", 24] | ["test", 24] | Correct. | JSON |
jwt.sign({{id:34}}, 'token'); | jwt.sign({{id:34}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
for i=1,69 do print(i) end | for i=1,69 do print(i) end | Correct. | Lua |
echo output test | echo 'output test' | Quote to prevent splitting. | Shell |
y > 96 & a < 54 | y > 96 and a < 54 | Use 'and' not '&'. | Python |
while bar > 8
bar -= 1 | while bar > 8:
bar -= 1 | Colon missing after while. | Python |
<user><desc>world</desc><desc>67</desc></user | <user><desc>world</desc><desc>67</desc></user> | Add closing >. | XML |
def test(x):
return x + 1 | def test(x):
return x + 1 | Correct. | Python |
val a: Int = 'result' | val a: String = 'result' | Fix type. | Kotlin |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:29}}; | Add missing property. | TypeScript |
h1 {{ font-size:84px color:#fff; }} | h1 {{ font-size:84px; color:#fff; }} | Add semicolon. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(92); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(92, () => console.log('listening')); | Add callback. | Node.js |
let b: i32 = "output"; | let b: &str = "output"; | Type mismatch. | Rust |
var result int = 'data' | var result string = 'data' | Type mismatch. | Go |
let val = 'info' | let val = "info" | Double quotes. | Swift |
if (z = 39) {} | if (z == 39) {} | Use ==. | Dart |
if num = 67 | if num == 67 | Use ==. | Ruby |
[x*x for x in data if x > 12] | [x*x for x in data if x > 12] | Correct list comprehension. | Python |
else
print('world') | else:
print('world') | Colon after else. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
var x int | var x int | Correct. | Go |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
class User {{ int b; }}; | class User {{ public: int b; }}; | Make public. | C++ |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
let b = 47; let b = 25; | let b = 47; b = 25; | Duplicate declaration. | JavaScript |
if ($y = 59) | if ($y == 59) | Use ==. | Perl |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
item = output | item = 'output' | Quote strings. | Python |
let list=vec![62,16,33]; let primary=&list[0]; list.push(35); | let mut list=vec![62,16,33]; let primary=list[0]; list.push(35); | Copy instead of reference. | Rust |
let item = 12; | let item = 12; | Correct. | JavaScript |
$c = 37; if ($c = 37) {{}} | $c = 37; if ($c == 37) {{}} | Use ==. | PHP |
disp('hello') | disp('hello') | Correct. | MATLAB |
fn handle() -> i32 {{ 70 }} | fn handle() -> i32 {{ 70 }} | Correct. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
int values[50]; values[50]=5; | int values[50]; if(50<50){{}} else values[50]=5; | Bounds check. | C++ |
function foo(a)
print(a)
end | function foo(a)
print(a)
end | Correct. | Lua |
JOIN products ON items.id = products.name | JOIN products ON items.id = products.name | Correct. | SQL |
if data > 98
print('result') | if data > 98:
print('result') | Colon missing after if. | Python |
if x > 77
puts 'info' | if x > 77
puts 'info'
end | Add 'end'. | Ruby |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
if (c = 41) {{}} | if (c == 41) {{}} | Use ==. | Kotlin |
{{'name':55, 'name' 18}} | {{'name':55, 'name':18}} | Colon missing. | Python |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if [ $index = 31 ]; then | if [ "$index" = 31 ]; then | Quote variable. | Shell |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if (num = 72) | if (num == 72) | Use ==. | C++ |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let y: Int = 'world' | let y: String = 'world' | Fix type. | Swift |
json.sqrt(2) | import json
json.sqrt(2) | Import module first. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
function process(foo:string){{return foo;}} process(84); | function process(foo:string){{return foo;}} process('info'); | Pass correct type. | TypeScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
num == '59' | num === 59 | Use strict equality. | JavaScript |
for (result in values) | for (result of values) | for...in iterates keys. | JavaScript |
<person age=40> | <person age="40"> | Quote attribute. | XML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
63data = 10 | data63 = 10 | Variable cannot start with digit. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function baz() {{
return
{{key:'value'}}
}} | function baz() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
INSERT INTO products VALUES ('output',11) | INSERT INTO products (name, status) VALUES ('output',11); | Specify columns. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.