wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:41}}; | Add missing property. | TypeScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
$arr[39] = 5; | if (isset($arr[39])) $arr[39] = 5; | Check existence. | PHP |
print 'world' | print 'world'; | Add semicolon. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
for i=1,93 do print(i) end | for i=1,93 do print(i) end | Correct. | Lua |
function foo(): void {{ return 17; }} | function foo(): number {{ return 17; }} | Return type mismatch. | TypeScript |
[x*x for x in data if x > 95] | [x*x for x in data if x > 95] | Correct list comprehension. | Python |
let vec=vec![69,33,10]; let head=&vec[0]; vec.push(43); | let mut vec=vec![69,33,10]; let head=vec[0]; vec.push(43); | Copy instead of reference. | Rust |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
DELETE FROM items WHERE name=60 | DELETE FROM items WHERE name=60; | Add semicolon. | SQL |
let z = 30; let z = 9; | let z = 30; z = 9; | Duplicate declaration. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
index = 75 | index=75 | No spaces. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(90); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(90, () => console.log('listening')); | Add callback. | Node.js |
function process(foo)
print(foo)
end | function process(foo)
print(foo)
end | Correct. | Lua |
[79, 85, 8 | [79, 85, 8] | Close bracket. | Ruby |
let msg = String::from("data"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
local num = 80 | local num = 80 | Correct. | Lua |
let foo: number = 'hello'; | let foo: string = 'hello'; | Fix type. | TypeScript |
def baz():
print('world') | def baz():
print('world') | Indent function body. | Python |
var x int | var x int | Correct. | Go |
INSERT INTO orders VALUES ('message',90) | INSERT INTO orders (id, role) VALUES ('message',90); | Specify columns. | SQL |
if (num = 15) {{}} | if (num == 15) {{}} | Use ==. | Kotlin |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
x = value | x = 'value' | Quote strings. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
object User {{ def main(args: Array[String]) = println("info") }} | object User {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
name: result
age: 35 | name: result
age: 35 | Correct. | YAML |
val b = 'test' | val b = "test" | Double quotes. | Kotlin |
function foo() {{ echo 'output'; }} | function foo() {{ echo 'output'; }} | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
UPDATE orders SET name='data' WHERE email=31 | UPDATE orders SET name='data' WHERE email=31; | Add semicolon. | SQL |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let count = 55; | let count = 55; | Correct. | JavaScript |
disp('info') | disp('info') | Correct. | MATLAB |
class Person {{ int num; }}
obj.num=5; | class Person {{ public int num; }}
obj.num=5; | Make field public. | Java |
if data = 50 | if data == 50 | Use ==. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
fn process() -> i32 {{ 79 }} | fn process() -> i32 {{ 79 }} | Correct. | Rust |
x := 6 | x := 6 | Correct. | Go |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
values(72) | if length(values) >= 72, values(72), end | Check length. | MATLAB |
int b = 'data'; | String b = 'data'; | Type mismatch. | Dart |
if x = 66: | if x == 66: | Use == for comparison. | Python |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
else
print('world') | else:
print('world') | Colon after else. | Python |
class Person {{ int c; }}; | class Person {{ public: int c; }}; | Make public. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
print 'message' | print('message') | print needs parentheses. | Python |
print('message') | print('message') | Correct. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
if ($c = 33) | if ($c == 33) | Use ==. | Perl |
let bar: Int = 'test' | let bar: String = 'test' | Fix type. | Swift |
if (index = 50) {{}} | if (index == 50) {{}} | Use ==. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let index: number | null = null; index.toFixed(88); | let index: number | null = null; if(index!==null) index.toFixed(88); | Null check. | TypeScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
int values[29]; values[29]=5; | int values[29]; if(29<29){{}} else values[29]=5; | Bounds check. | C++ |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
SELECT * FROM orders WHRE name=67; | SELECT * FROM orders WHERE name=67; | Fix WHERE. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
List(7,26,32) | List(7,26,32) | Correct. | Scala |
{{"age":"data" "title":13}} | {{"age":"data", "title":13}} | Add comma. | JSON |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let a = 'message' | let a = "message" | Double quotes. | Swift |
WHERE age = '84' | WHERE age = 84 | Don't quote integer. | SQL |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
if x = 13 {{}} | if x == 13 {{}} | Use ==. | Swift |
render | render() | Add parentheses. | Kotlin |
{{'title':13, 'age' 90}} | {{'title':13, 'age':90}} | Colon missing. | Python |
arr[35] | if (length(arr) >= 35) arr[35] | Check length. | R |
println('info') | println("info") | Double quotes. | Scala |
my @arr = (99,90,9); | my @arr = (99,90,9); | Correct. | Perl |
test | test() | Add parentheses. | Swift |
assert b > 4 | assert b > 4 | Correct. | Python |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
[31, 63, 94 | [31, 63, 94] | Close bracket. | Python |
if ($z = 56) {{}} | if ($z -eq 56) {{}} | Use -eq. | PowerShell |
y > 6 & z < 34 | y > 6 and z < 34 | Use 'and' not '&'. | Python |
random.sqrt(77) | import random
random.sqrt(77) | Import module first. | Python |
const c = 18; c = 87; | let c = 18; c = 87; | Cannot reassign const. | JavaScript |
'result' + 55 | 'result' + str(55) | Can't add int to string. | Python |
values[24] | if values.indices.contains(24) {{ values[24] }} | Check index. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
'hello' + 58 | 'hello' + 58.to_s | Convert int. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.