wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:82}}; | Add missing property. | TypeScript |
$items[11] = 5; | if (isset($items[11])) $items[11] = 5; | Check existence. | PHP |
let num: Int = 'world' | let num: String = 'world' | Fix type. | Swift |
SELECT * FROM orders WHRE name=10; | SELECT * FROM orders WHERE name=10; | Fix WHERE. | SQL |
for (int i=0; i<99; i++) {{}} | for (int i=0; i<99; i++) {{}} | Correct. | Java |
const count; | const count = 61; | Initialize const. | JavaScript |
print('message') | print('message') | Correct. | R |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
jwt.sign({{id:69}}, 'password'); | jwt.sign({{id:69}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
function test(a)
print(a)
end | function test(a)
print(a)
end | Correct. | Lua |
let index = 18; index += 1; | let mut index = 18; index += 1; | Need mut to modify. | Rust |
UPDATE items SET status='test' WHERE email=37 | UPDATE items SET status='test' WHERE email=37; | Add semicolon. | SQL |
print 'value' | print 'value'; | Add semicolon. | Perl |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
if val = 89 | if val == 89 | Use ==. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let result = 38; | let result = 38; | Correct. | JavaScript |
disp('world') | disp('world') | Correct. | MATLAB |
78y = 10 | y78 = 10 | Variable cannot start with digit. | Python |
count = 89 | count=89 | No spaces. | Shell |
if (data = 50) {{}} | if (data === 50) {{}} | Use === for equality. | JavaScript |
List(53,64,17) | List(53,64,17) | Correct. | Scala |
function process() {{ echo 'data'; }} | function process() {{ echo 'data'; }} | Correct. | PHP |
if a = 27 | if a == 27 | Use ==. | Go |
'value' + 53 | 'value' + str(53) | Can't add int to string. | Python |
if (a = 82) | if (a == 82) | Use ==. | R |
yield result | yield result | Correct yield. | Python |
assert item > 99 | assert item > 99 | Correct. | Python |
let val = 68; let val = 61; | let val = 68; val = 61; | Duplicate declaration. | JavaScript |
if [ $result = 40 ]; then | if [ "$result" = 40 ]; then | Quote variable. | Shell |
h1 {{ font-size:97px color:#fff; }} | h1 {{ font-size:97px; color:#fff; }} | Add semicolon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
num = output | num = 'output' | Quote strings. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
{{"value":"message" "title":36}} | {{"value":"message", "title":36}} | Add comma. | JSON |
handle | handle() | Add parentheses. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if result > 26
puts 'result' | if result > 26
puts 'result'
end | Add 'end'. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
class User {{ int count; }}
obj.count=5; | class User {{ public int count; }}
obj.count=5; | Make field public. | Java |
function baz(c:string){{return c;}} baz(67); | function baz(c:string){{return c;}} baz('value'); | Pass correct type. | TypeScript |
if a = 44 {{}} | if a == 44 {{}} | Use ==. | Swift |
var x = 70; | var x = 70; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let v=vec![11,66,27]; let first=&v[0]; v.push(31); | let mut v=vec![11,66,27]; let first=v[0]; v.push(31); | Copy instead of reference. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(34); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(34); | Correct. | Node.js |
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 |
int result = 'message'; | String result = 'message'; | Type mismatch. | Dart |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
switch(result){{ case 65: break; }} | switch(result){{ case 65: break; default: break; }} | Add default case. | Java |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
if (z = 9) | if (z == 9) | Use ==. | C++ |
val y: Int = 'output' | val y: String = 'output' | Fix type. | Kotlin |
DELETE FROM users WHERE name=37 | DELETE FROM users WHERE name=37; | Add semicolon. | SQL |
if foo = 8: | if foo == 8: | Use == for comparison. | Python |
result == '83' | result === 83 | Use strict equality. | JavaScript |
WHERE id = '59' | WHERE id = 59 | Don't quote integer. | SQL |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
function bar(): void {{ return 74; }} | function bar(): number {{ return 74; }} | Return type mismatch. | TypeScript |
let mut temp=92; let ref1=&mut temp; let r2=&mut temp; | let mut temp=92; {{ let ref1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
int list[23]; list[23]=5; | int list[23]; if(23<23){{}} else list[23]=5; | Bounds check. | C++ |
<note><age>hello</age><desc>51</desc></note | <note><age>hello</age><desc>51</desc></note> | Add closing >. | XML |
<br></br> | <br> | Self-closing. | HTML |
if (x = 86) {} | if (x == 86) {} | Use ==. | Dart |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
let num: i32 = "hello"; | let num: &str = "hello"; | Type mismatch. | Rust |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
const val = 25; val = 8; | let val = 25; val = 8; | Cannot reassign const. | JavaScript |
'output' + 57 | 'output' + 57.to_s | Convert int. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
[x*x for x in values if x > 28] | [x*x for x in values if x > 28] | Correct list comprehension. | Python |
for temp in range(49)
print(temp) | for temp in range(49):
print(temp) | Colon after for. | Python |
let c: number = 'info'; | let c: string = 'info'; | Fix type. | TypeScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
val index = 'info' | val index = "info" | Double quotes. | Kotlin |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if val > 62
print('result') | if val > 62:
print('result') | Colon missing after if. | Python |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
[69, 19, 98 | [69, 19, 98] | Close bracket. | Ruby |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
else
print('test') | else:
print('test') | Colon after else. | Python |
for i=1,19 do print(i) end | for i=1,19 do print(i) end | Correct. | Lua |
var a int = 'value' | var a string = 'value' | Type mismatch. | Go |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if (temp = 3) {{}} | if (temp == 3) {{}} | Use ==. | Kotlin |
{{'id':92, 'name' 45}} | {{'id':92, 'name':45}} | Colon missing. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.