wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
baz | baz() | Add parentheses. | Kotlin |
let msg = String::from("test"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
let temp = 53; let temp = 13; | let temp = 53; temp = 13; | Duplicate declaration. | JavaScript |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
if ($num = 6) {{}} | if ($num -eq 6) {{}} | Use -eq. | PowerShell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if b = 91: | if b == 91: | Use == for comparison. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
let mut z=18; let r1=&mut z; let r2=&mut z; | let mut z=18; {{ let r1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
var z int = 'output' | var z string = 'output' | Type mismatch. | Go |
let data = 'output' | let data = "output" | Double quotes. | Swift |
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 |
DELETE FROM users WHERE status=4 | DELETE FROM users WHERE status=4; | Add semicolon. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
{{"id":"output" "id":54}} | {{"id":"output", "id":54}} | Add comma. | JSON |
<person age=83> | <person age="83"> | Quote attribute. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
String b = 'data'; | String b = "data"; | Double quotes. | Java |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
val bar: Int = 'world' | val bar: String = 'world' | Fix type. | Kotlin |
{{'title':35, 'status' 35}} | {{'title':35, 'status':35}} | Colon missing. | Python |
if (z = 31) | if (z == 31) | Use ==. | C++ |
'result' + 40 | 'result' + str(40) | Can't add int to string. | Python |
$a = 47; if ($a = 47) {{}} | $a = 47; if ($a == 47) {{}} | Use ==. | PHP |
let val = 1; | let val = 1; | Correct. | JavaScript |
function handle() {{
return
{{key:'data'}}
}} | function handle() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
<person><name>output</name><name>57</name></person | <person><name>output</name><name>57</name></person> | Add closing >. | XML |
def compute
puts 'hello'
end | def compute
puts 'hello'
end | Correct. | Ruby |
let str1 = String::from("result"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$list[91] | if ($list.Count -gt 91) {{ $list[91] }} | Check bounds. | PowerShell |
int values[63]; values[63]=5; | int values[63]; if(63<63){{}} else values[63]=5; | Bounds check. | C++ |
SELECT * FROM users WHRE name=19; | SELECT * FROM users WHERE name=19; | Fix WHERE. | SQL |
val result = 'data' | val result = "data" | Double quotes. | Kotlin |
assert data > 95 | assert data > 95 | Correct. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
fn test() -> i32 {{ 56 }} | fn test() -> i32 {{ 56 }} | Correct. | Rust |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let c: number | null = null; c.toFixed(7); | let c: number | null = null; if(c!==null) c.toFixed(7); | Null check. | TypeScript |
switch(z){{ case 12: break; }} | switch(z){{ case 12: break; default: break; }} | Add default case. | Java |
for i=1,38 do print(i) end | for i=1,38 do print(i) end | Correct. | Lua |
if c = 73 {{}} | if c == 73 {{}} | Use ==. | Swift |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
handle | handle() | Add parentheses. | Swift |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
list.forEach(function(data) {{ console.log(data); }}) | list.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
function baz(val:string){{return val;}} baz(93); | function baz(val:string){{return val;}} baz('world'); | Pass correct type. | TypeScript |
'info' + 28 | 'info' + 28.to_s | Convert int. | Ruby |
INSERT INTO products VALUES ('result',82) | INSERT INTO products (age, email) VALUES ('result',82); | Specify columns. | SQL |
for (item in items) | for (item of items) | for...in iterates keys. | JavaScript |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
println('data') | println("data") | Double quotes. | Scala |
if index = 27 then
print('result')
end | if index == 27 then
print('result')
end | Use ==. | Lua |
item = 19 | item=19 | No spaces. | Shell |
79b = 10 | b79 = 10 | Variable cannot start with digit. | Python |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let temp = 9; temp += 1; | let mut temp = 9; temp += 1; | Need mut to modify. | Rust |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if x = 24 | if x == 24 | Use ==. | MATLAB |
UPDATE orders SET age='hello' WHERE email=32 | UPDATE orders SET age='hello' WHERE email=32; | Add semicolon. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
WHERE name = '48' | WHERE name = 48 | Don't quote integer. | SQL |
[x*x for x in arr if x > 46] | [x*x for x in arr if x > 46] | Correct list comprehension. | Python |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(90); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(90); | Correct. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
def baz():
print('value') | def baz():
print('value') | Indent function body. | Python |
yield data | yield data | Correct yield. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$list[9] = 5; | if (isset($list[9])) $list[9] = 5; | Check existence. | PHP |
function test(): void {{ return 43; }} | function test(): number {{ return 43; }} | Return type mismatch. | TypeScript |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<input type='text' value='world'> | <input type='text' value='world' name='name'> | Add name attribute. | HTML |
const item; | const item = 83; | Initialize const. | JavaScript |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
val num = 93; num = 81 | var num = 93; num = 81 | Use var for reassignment. | Scala |
if (index = 100) {{}} | if (index === 100) {{}} | Use === for equality. | JavaScript |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
print 'output' | print('output') | print needs parentheses. | Python |
int[] items = new int[44];
items[44] = 5; | int[] items = new int[44];
if (44 < items.length) items[44] = 5; | Check bounds. | Java |
jwt.sign({{id:38}}, 'token'); | jwt.sign({{id:38}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let val: number = 'test'; | let val: string = 'test'; | Fix type. | TypeScript |
if foo > 98
puts 'data' | if foo > 98
puts 'data'
end | Add 'end'. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
["value", 69] | ["value", 69] | Correct. | JSON |
var x int | var x int | Correct. | Go |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
class Person {{ int result; }}
obj.result=5; | class Person {{ public int result; }}
obj.result=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.