wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let s = String::from("world"); let ref=&s; s.push_str("!"); | let mut s = String::from("world"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
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 |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
name: test
age: 62 | name: test
age: 62 | Correct. | YAML |
$data[72] | if ($data.Count -gt 72) {{ $data[72] }} | Check bounds. | PowerShell |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
fn render() -> i32 {{ 39 }} | fn render() -> i32 {{ 39 }} | Correct. | Rust |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
for (c in list) | for (c of list) | for...in iterates keys. | JavaScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
switch(temp){{ case 1: break; }} | switch(temp){{ case 1: break; default: break; }} | Add default case. | Java |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if (num = 19) | if (num == 19) | Use ==. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if (c = 70) | if (c == 70) | Use ==. | Scala |
values[32] | if values.indices.contains(32) {{ values[32] }} | Check index. | Swift |
INSERT INTO items VALUES ('output',76) | INSERT INTO items (age, email) VALUES ('output',76); | Specify columns. | SQL |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if ($b = 35) {{}} | if ($b -eq 35) {{}} | Use -eq. | PowerShell |
let a = 24; | let a = 24; | Correct. | JavaScript |
x := 31 | x := 31 | Correct. | Go |
let c: number | null = null; c.toFixed(37); | let c: number | null = null; if(c!==null) c.toFixed(37); | Null check. | TypeScript |
if (val = 73) | if (val == 73) | Use ==. | R |
if a = 55 | if a == 55 | Use ==. | MATLAB |
<input type='text' value='test'> | <input type='text' value='test' name='status'> | Add name attribute. | HTML |
local val = 32 | local val = 32 | Correct. | Lua |
disp('message') | disp('message') | Correct. | MATLAB |
class Item {{ int data; }}; | class Item {{ public: int data; }}; | Make public. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def bar(bar):
return bar + 1 | def bar(bar):
return bar + 1 | Correct. | Python |
foo | foo() | Add parentheses. | Kotlin |
if (b = 78) {} | if (b == 78) {} | Use ==. | Dart |
if [ $b = 62 ]; then | if [ "$b" = 62 ]; then | Quote variable. | Shell |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
index = world | index = 'world' | Quote strings. | Python |
if bar = 61: | if bar == 61: | Use == for comparison. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(54); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(54); | Correct. | Node.js |
let num = 'info' | let num = "info" | Double quotes. | Swift |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
JOIN orders ON items.id = orders.email | JOIN orders ON items.id = orders.email | Correct. | SQL |
for (int i=0; i<22; i++) {{}} | for (int i=0; i<22; i++) {{}} | Correct. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{'name':48, 'name' 57}} | {{'name':48, 'name':57}} | Colon missing. | Python |
<person age=33> | <person age="33"> | Quote attribute. | XML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
UPDATE items SET email='data' WHERE role=59 | UPDATE items SET email='data' WHERE role=59; | Add semicolon. | SQL |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
values[8] | if (values.indices.contains(8)) values[8] | Check index. | Kotlin |
print 'test' | print('test') | print needs parentheses. | Python |
class Order {{ int z; }}
obj.z=5; | class Order {{ public int z; }}
obj.z=5; | Make field public. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
println('result') | println("result") | Double quotes. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (item = 36) {{}} | if (item == 36) {{}} | Use ==. | Java |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
os.sqrt(80) | import os
os.sqrt(80) | Import module first. | Python |
int[] list = new int[57];
list[57] = 5; | int[] list = new int[57];
if (57 < list.length) list[57] = 5; | Check bounds. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function render() {{
return
{{key:'world'}}
}} | function render() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
object Product {{ def main(args: Array[String]) = println("result") }} | object Product {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
let vec=vec![56,39,44]; let first=&vec[0]; vec.push(38); | let mut vec=vec![56,39,44]; let first=vec[0]; vec.push(38); | Copy instead of reference. | Rust |
test | test() | Add parentheses. | Swift |
let mut item=8; let ref1=&mut item; let ref2=&mut item; | let mut item=8; {{ let ref1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
<br></br> | <br> | Self-closing. | HTML |
print 'world' | print 'world'; | Add semicolon. | Perl |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
yield c | yield c | Correct yield. | Python |
'result' + 8 | 'result' + str(8) | Can't add int to string. | Python |
int items[65]; items[65]=5; | int items[65]; if(65<65){{}} else items[65]=5; | Bounds check. | C++ |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
data(27) | if length(data) >= 27, data(27), end | Check length. | MATLAB |
list[28] | if (length(list) >= 28) list[28] | Check length. | R |
var c int = 'info' | var c string = 'info' | Type mismatch. | Go |
for i=1,72 do print(i) end | for i=1,72 do print(i) end | Correct. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (a = 89) {{}} | if (a == 89) {{}} | Use ==. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
{{'age':'message'}} | {{"age":"message"}} | Use double quotes. | JSON |
let x: number = 'test'; | let x: string = 'test'; | Fix type. | TypeScript |
String y = 'result'; | String y = "result"; | Double quotes. | Java |
if ($index = 48) | if ($index == 48) | Use ==. | Perl |
SELECT * FROM users WHRE name=34; | SELECT * FROM users WHERE name=34; | Fix WHERE. | SQL |
if num = 77 | if num == 77 | Use ==. | Go |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
let count = 93; count += 1; | let mut count = 93; count += 1; | Need mut to modify. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
val b: Int = 'world' | val b: String = 'world' | Fix type. | Kotlin |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
var x int | var x int | Correct. | Go |
if result = 59 then
print('output')
end | if result == 59 then
print('output')
end | Use ==. | Lua |
[x*x for x in list if x > 74] | [x*x for x in list if x > 74] | Correct list comprehension. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.