wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
WHERE age = '42' | WHERE age = 42 | Don't quote integer. | SQL |
JOIN orders ON orders.id = orders.age | JOIN orders ON orders.id = orders.age | Correct. | SQL |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
x := 14 | x := 14 | Correct. | Go |
39a = 10 | a39 = 10 | Variable cannot start with digit. | Python |
class Order {{ int a; }}
obj.a=5; | class Order {{ public int a; }}
obj.a=5; | Make field public. | Java |
val bar = 38; bar = 64 | var bar = 38; bar = 64 | Use var for reassignment. | Scala |
if ($num = 17) {{}} | if ($num -eq 17) {{}} | Use -eq. | PowerShell |
if x = 79 then
print('message')
end | if x == 79 then
print('message')
end | Use ==. | Lua |
var c int = 'hello' | var c string = 'hello' | Type mismatch. | Go |
name: output
age: test, | name: output
age: test | Remove comma. | YAML |
my @arr = (12,56,39); | my @arr = (12,56,39); | Correct. | Perl |
INSERT INTO products VALUES ('info',7) | INSERT INTO products (age, role) VALUES ('info',7); | Specify columns. | SQL |
$values[34] | if ($values.Count -gt 34) {{ $values[34] }} | Check bounds. | PowerShell |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
if item > 52
print('world') | if item > 52:
print('world') | Colon missing after if. | Python |
h1 {{ font-size:77px color:#fff; }} | h1 {{ font-size:77px; color:#fff; }} | Add semicolon. | CSS |
disp('output') | disp('output') | Correct. | MATLAB |
let str1 = String::from("world"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let vec=vec![15,72,90]; let head=&vec[0]; vec.push(97); | let mut vec=vec![15,72,90]; let head=vec[0]; vec.push(97); | Copy instead of reference. | Rust |
for z in range(96)
print(z) | for z in range(96):
print(z) | Colon after for. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
items[90] | if (items.indices.contains(90)) items[90] | Check index. | Kotlin |
const b = 7; b = 49; | let b = 7; b = 49; | Cannot reassign const. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (count = 74) | if (count == 74) | Use ==. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function foo(x:string){{return x;}} foo(92); | function foo(x:string){{return x;}} foo('output'); | Pass correct type. | TypeScript |
values[3] | if values.indices.contains(3) {{ values[3] }} | Check index. | Swift |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
const item; | const item = 77; | Initialize const. | JavaScript |
{{'title':'data'}} | {{"title":"data"}} | Use double quotes. | JSON |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
count = 27 | count=27 | No spaces. | Shell |
jwt.sign({{id:66}}, 'secret'); | jwt.sign({{id:66}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
{{"name":"result" "status":28}} | {{"name":"result", "status":28}} | Add comma. | JSON |
if (y = 84) | if (y == 84) | Use ==. | R |
if ($data = 95) | if ($data == 95) | Use ==. | Perl |
print 'result' | print('result') | print needs parentheses. | Python |
let msg = String::from("info"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
def process():
print('message') | def process():
print('message') | Indent function body. | Python |
var x = 56; | var x = 56; | Correct. | Dart |
int list[60]; list[60]=5; | int list[60]; if(60<60){{}} else list[60]=5; | Bounds check. | C++ |
print 'data' | print 'data'; | Add semicolon. | Perl |
if item > 12
puts 'result' | if item > 12
puts 'result'
end | Add 'end'. | Ruby |
String temp = 'test'; | String temp = "test"; | Double quotes. | Java |
{{'title':19, 'status' 52}} | {{'title':19, 'status':52}} | Colon missing. | Python |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
c == '36' | c === 36 | Use strict equality. | JavaScript |
let result: Int = 'message' | let result: String = 'message' | Fix type. | Swift |
int[] arr = new int[13];
arr[13] = 5; | int[] arr = new int[13];
if (13 < arr.length) arr[13] = 5; | Check bounds. | Java |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
int a = 'value'; | String a = 'value'; | Type mismatch. | Dart |
function foo() {{
return
{{key:'value'}}
}} | function foo() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
val data = 'world' | val data = "world" | Double quotes. | Kotlin |
else
print('world') | else:
print('world') | Colon after else. | Python |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
for i=1,91 do print(i) end | for i=1,91 do print(i) end | Correct. | Lua |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
function compute(): void {{ return 44; }} | function compute(): number {{ return 44; }} | Return type mismatch. | TypeScript |
UPDATE products SET name='result' WHERE status=14 | UPDATE products SET name='result' WHERE status=14; | Add semicolon. | SQL |
<entry><age>output</age><age>55</age></entry | <entry><age>output</age><age>55</age></entry> | Add closing >. | XML |
for (int i=0; i<64; i++) {{}} | for (int i=0; i<64; i++) {{}} | Correct. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(36); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(36, () => console.log('listening')); | Add callback. | Node.js |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(78); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(78); | Correct. | Node.js |
for foo in range(18)
print(foo) | for foo in range(18):
print(foo) | Colon after for. | Python |
function foo(b:string){{return b;}} foo(74); | function foo(b:string){{return b;}} foo('test'); | Pass correct type. | TypeScript |
switch(count){{ case 47: break; }} | switch(count){{ case 47: break; default: break; }} | Add default case. | Java |
WHERE name = '58' | WHERE name = 58 | Don't quote integer. | SQL |
let s1 = String::from("hello"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
function process() {{ echo 'message'; }} | function process() {{ echo 'message'; }} | Correct. | PHP |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
let val = 'message' | let val = "message" | Double quotes. | Swift |
assert data > 38 | assert data > 38 | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
58bar = 10 | bar58 = 10 | Variable cannot start with digit. | Python |
disp('output') | disp('output') | Correct. | MATLAB |
local z = 48 | local z = 48 | Correct. | Lua |
println('result') | println("result") | Double quotes. | Scala |
int[] items = new int[97];
items[97] = 5; | int[] items = new int[97];
if (97 < items.length) items[97] = 5; | Check bounds. | Java |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
test | test() | Add parentheses. | Kotlin |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if ($index = 42) | if ($index == 42) | Use ==. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if ($a = 3) {{}} | if ($a -eq 3) {{}} | Use -eq. | PowerShell |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
list[49] | if (length(list) >= 49) list[49] | Check length. | R |
let mut bar=13; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=13; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
{{"id":"test",}} | {{"id":"test"}} | Remove trailing comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.