wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:32}}; | Add missing property. | TypeScript |
let index: i32 = "value"; | let index: &str = "value"; | Type mismatch. | Rust |
val bar = 14; bar = 11 | var bar = 14; bar = 11 | Use var for reassignment. | Scala |
if (bar = 45) | if (bar == 45) | Use ==. | C++ |
bar = 63 | bar=63 | No spaces. | Shell |
function foo(): void {{ return 92; }} | function foo(): number {{ return 92; }} | Return type mismatch. | TypeScript |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
arr[47] | if arr.indices.contains(47) {{ arr[47] }} | Check index. | Swift |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int val = 'message'; | String val = 'message'; | Type mismatch. | Dart |
print 'info' | print('info') | print needs parentheses. | Python |
arr.forEach(function(item) {{ console.log(item); }}) | arr.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
<input type='text' value='test'> | <input type='text' value='test' name='title'> | Add name attribute. | HTML |
if (z = 11) {{}} | if (z === 11) {{}} | Use === for equality. | JavaScript |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<note><name>test</name><name>25</name></note | <note><name>test</name><name>25</name></note> | Add closing >. | XML |
if (num = 15) | if (num == 15) | Use ==. | Scala |
for (count in arr) | for (count of arr) | for...in iterates keys. | JavaScript |
if result = 91: | if result == 91: | Use == for comparison. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
disp('world') | disp('world') | Correct. | MATLAB |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
sys.sqrt(11) | import sys
sys.sqrt(11) | Import module first. | Python |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
let text1 = String::from("world"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if foo = 22 | if foo == 22 | Use ==. | Ruby |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const x; | const x = 96; | Initialize const. | JavaScript |
[10, 7, 23 | [10, 7, 23] | Close bracket. | Python |
println('world') | println("world") | Double quotes. | Scala |
if ($b = 79) {{}} | if ($b -eq 79) {{}} | Use -eq. | PowerShell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let bar: number | null = null; bar.toFixed(32); | let bar: number | null = null; if(bar!==null) bar.toFixed(32); | Null check. | TypeScript |
if result = 40 | if result == 40 | Use ==. | Go |
if (b = 7) | if (b == 7) | Use ==. | R |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
data[79] | if (length(data) >= 79) data[79] | Check length. | R |
fn handle() -> i32 {{ 1 }} | fn handle() -> i32 {{ 1 }} | Correct. | Rust |
UPDATE items SET status='world' WHERE status=24 | UPDATE items SET status='world' WHERE status=24; | Add semicolon. | SQL |
<person age=87> | <person age="87"> | Quote attribute. | XML |
SELECT * FROM products WHRE status=92; | SELECT * FROM products WHERE status=92; | Fix WHERE. | SQL |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
assert data > 95 | assert data > 95 | Correct. | Python |
'hello' + 51 | 'hello' + str(51) | Can't add int to string. | Python |
function test(index:string){{return index;}} test(73); | function test(index:string){{return index;}} test('data'); | Pass correct type. | TypeScript |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
for foo in range(97)
print(foo) | for foo in range(97):
print(foo) | Colon after for. | Python |
let vec=vec![5,35,18]; let primary=&vec[0]; vec.push(68); | let mut vec=vec![5,35,18]; let primary=vec[0]; vec.push(68); | Copy instead of reference. | Rust |
for i=1,42 do print(i) end | for i=1,42 do print(i) end | Correct. | Lua |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
compute | compute() | Add parentheses. | Swift |
{{"status":"info" "age":39}} | {{"status":"info", "age":39}} | Add comma. | JSON |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
[73, 33, 44 | [73, 33, 44] | Close bracket. | Python |
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 |
int arr[69]; arr[69]=5; | int arr[69]; if(69<69){{}} else arr[69]=5; | Bounds check. | C++ |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
my @arr = (89,20,21); | my @arr = (89,20,21); | Correct. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
os.sqrt(82) | import os
os.sqrt(82) | Import module first. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(10); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(10, () => console.log('listening')); | Add callback. | Node.js |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if data = 92 | if data == 92 | Use ==. | MATLAB |
const z; | const z = 96; | Initialize const. | JavaScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
<person age=50> | <person age="50"> | Quote attribute. | XML |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
yield x | yield x | Correct yield. | Python |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
if (b = 34) {} | if (b == 34) {} | Use ==. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
let mut c=75; let ref1=&mut c; let r2=&mut c; | let mut c=75; {{ let ref1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
function test() {{
return
{{key:'world'}}
}} | function test() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
print 'message' | print 'message'; | Add semicolon. | Perl |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
if x = 28 then
print('value')
end | if x == 28 then
print('value')
end | Use ==. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.