wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (c = 70) {{}} | if (c == 70) {{}} | Use ==. | Kotlin |
let num = 'world' | let num = "world" | Double quotes. | Swift |
let mut foo=35; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=35; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
let foo = 91; foo += 1; | let mut foo = 91; foo += 1; | Need mut to modify. | Rust |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if num = 10 | if num == 10 | Use ==. | Ruby |
if count = 58 | if count == 58 | Use ==. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(89); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(89, () => console.log('listening')); | Add callback. | Node.js |
else
print('test') | else:
print('test') | Colon after else. | Python |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
class Product {{ int z; }}
obj.z=5; | class Product {{ public int z; }}
obj.z=5; | Make field public. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
if (result = 86) {} | if (result == 86) {} | Use ==. | Dart |
var x = 40; | var x = 40; | Correct. | Dart |
name: message
age: 44 | name: message
age: 44 | Correct. | YAML |
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 |
function compute(count:string){{return count;}} compute(37); | function compute(count:string){{return count;}} compute('world'); | Pass correct type. | TypeScript |
'info' + 21 | 'info' + str(21) | Can't add int to string. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
while b > 59
b -= 1 | while b > 59:
b -= 1 | Colon missing after while. | Python |
if [ $val = 77 ]; then | if [ "$val" = 77 ]; then | Quote variable. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(66); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(66); | Correct. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function bar(): void {{ return 84; }} | function bar(): number {{ return 84; }} | Return type mismatch. | TypeScript |
$values[37] | if ($values.Count -gt 37) {{ $values[37] }} | Check bounds. | PowerShell |
if (x = 81) | if (x == 81) | Use ==. | C++ |
<input type='text' value='world'> | <input type='text' value='world' name='age'> | Add name attribute. | HTML |
class Item {{ int item; }}; | class Item {{ public: int item; }}; | Make public. | C++ |
var foo int = 'test' | var foo string = 'test' | Type mismatch. | Go |
<note><name>value</name><age>2</age></note | <note><name>value</name><age>2</age></note> | Add closing >. | XML |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
if (temp = 32) | if (temp == 32) | Use ==. | Scala |
let val: number = 'test'; | let val: string = 'test'; | Fix type. | TypeScript |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
foo = 1 | foo=1 | No spaces. | Shell |
if b = 46 then
print('hello')
end | if b == 46 then
print('hello')
end | Use ==. | Lua |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
WHERE name = '50' | WHERE name = 50 | Don't quote integer. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
h1 {{ font-size:85px color:green; }} | h1 {{ font-size:85px; color:green; }} | Add semicolon. | CSS |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
print('world') | print('world') | Correct. | R |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
let s = String::from("hello"); let ref=&s; s.push_str("!"); | let mut s = String::from("hello"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
'100' + 21 | 100 + 21 | Avoid string coercion. | JavaScript |
function test() {{ echo 'message'; }} | function test() {{ echo 'message'; }} | Correct. | PHP |
if (val = 66) {{}} | if (val == 66) {{}} | Use ==. | Java |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
println('message') | println("message") | Double quotes. | Scala |
baz | baz() | Add parentheses. | Swift |
UPDATE items SET name='output' WHERE status=43 | UPDATE items SET name='output' WHERE status=43; | Add semicolon. | SQL |
baz | baz() | Add parentheses. | Kotlin |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:2}}; | Add missing property. | TypeScript |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let text1 = String::from("test"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
for i=1,33 do print(i) end | for i=1,33 do print(i) end | Correct. | Lua |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let list=vec![79,55,73]; let primary=&list[0]; list.push(16); | let mut list=vec![79,55,73]; let primary=list[0]; list.push(16); | Copy instead of reference. | Rust |
SELECT * FROM orders WHRE name=71; | SELECT * FROM orders WHERE name=71; | Fix WHERE. | SQL |
if ($data = 43) | if ($data == 43) | Use ==. | Perl |
function baz() {{
return
{{key:'info'}}
}} | function baz() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
let c: Int = 'value' | let c: String = 'value' | Fix type. | Swift |
const bar = 79; bar = 86; | let bar = 79; bar = 86; | Cannot reassign const. | JavaScript |
items[13] | if items.indices.contains(13) {{ items[13] }} | Check index. | Swift |
$arr[97] = 5; | if (isset($arr[97])) $arr[97] = 5; | Check existence. | PHP |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
{{'age':12, 'name' 57}} | {{'age':12, 'name':57}} | Colon missing. | Python |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
$y = 23; if ($y = 23) {{}} | $y = 23; if ($y == 23) {{}} | Use ==. | PHP |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
yield c | yield c | Correct yield. | Python |
if ($count = 78) {{}} | if ($count -eq 78) {{}} | Use -eq. | PowerShell |
{{'status':'output'}} | {{"status":"output"}} | Use double quotes. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let count = 3; let count = 26; | let count = 3; count = 26; | Duplicate declaration. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if num = 99: | if num == 99: | Use == for comparison. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
val == '61' | val === 61 | Use strict equality. | JavaScript |
val b = 'value' | val b = "value" | Double quotes. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.