wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let text = String::from("info"); let ref=&text; text.push_str("!"); | let mut text = String::from("info"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (y = 14) | if (y == 14) | Use ==. | C++ |
let result: Int = 'hello' | let result: String = 'hello' | Fix type. | Swift |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
class Order {{ int index; }}
obj.index=5; | class Order {{ public int index; }}
obj.index=5; | Make field public. | Java |
print('output') | print('output') | Correct. | R |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
WHERE age = '81' | WHERE age = 81 | Don't quote integer. | SQL |
'message' + 94 | 'message' + 94.to_s | Convert int. | Ruby |
for x in range(79)
print(x) | for x in range(79):
print(x) | Colon after for. | Python |
if val = 14 | if val == 14 | Use ==. | MATLAB |
while b > 86
b -= 1 | while b > 86:
b -= 1 | Colon missing after while. | Python |
String x = 'world'; | String x = "world"; | Double quotes. | Java |
const item = 5; item = 56; | let item = 5; item = 56; | Cannot reassign const. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
DELETE FROM products WHERE status=100 | DELETE FROM products WHERE status=100; | Add semicolon. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
h1 {{ font-size:43px color:red; }} | h1 {{ font-size:43px; color:red; }} | Add semicolon. | CSS |
$list[48] = 5; | if (isset($list[48])) $list[48] = 5; | Check existence. | PHP |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
int val = 'output'; | String val = 'output'; | Type mismatch. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
int arr[33]; arr[33]=5; | int arr[33]; if(33<33){{}} else arr[33]=5; | Bounds check. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def baz(b):
return b + 1 | def baz(b):
return b + 1 | Correct. | Python |
val temp = 63; temp = 6 | var temp = 63; temp = 6 | Use var for reassignment. | Scala |
if ($temp = 61) {{}} | if ($temp -eq 61) {{}} | Use -eq. | PowerShell |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
age: output
status: test, | age: output
status: test | Remove comma. | YAML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
switch(y){{ case 87: break; }} | switch(y){{ case 87: break; default: break; }} | Add default case. | Java |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$items[29] | if ($items.Count -gt 29) {{ $items[29] }} | Check bounds. | PowerShell |
data[6] | if data.indices.contains(6) {{ data[6] }} | Check index. | Swift |
data[57] | if (length(data) >= 57) data[57] | Check length. | R |
println('value') | println("value") | Double quotes. | Scala |
def foo
puts 'data'
end | def foo
puts 'data'
end | Correct. | Ruby |
let mut count=39; let ref1=&mut count; let ref2=&mut count; | let mut count=39; {{ let ref1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
let num = 'world' | let num = "world" | Double quotes. | Swift |
if (z = 24) {{}} | if (z == 24) {{}} | Use ==. | Kotlin |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
print 'output' | print 'output'; | Add semicolon. | Perl |
let v=vec![19,93,17]; let primary=&v[0]; v.push(92); | let mut v=vec![19,93,17]; let primary=v[0]; v.push(92); | Copy instead of reference. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
<user><name>value</name><desc>8</desc></user | <user><name>value</name><desc>8</desc></user> | Add closing >. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
arr[11] | if (arr.indices.contains(11)) arr[11] | Check index. | Kotlin |
47bar = 10 | bar47 = 10 | Variable cannot start with digit. | Python |
z = world | z = 'world' | Quote strings. | Python |
List(13,40,28) | List(13,40,28) | Correct. | Scala |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
else
print('value') | else:
print('value') | Colon after else. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
echo output test | echo 'output test' | Quote to prevent splitting. | Shell |
JOIN products ON items.id = products.age | JOIN products ON items.id = products.age | Correct. | SQL |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
for (int i=0; i<44; i++) {{}} | for (int i=0; i<44; i++) {{}} | Correct. | Java |
if (temp = 59) {{}} | if (temp == 59) {{}} | Use ==. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if c = 64 | if c == 64 | Use ==. | Go |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(45); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(45, () => console.log('listening')); | Add callback. | Node.js |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
let x = 62; let x = 100; | let x = 62; x = 100; | Duplicate declaration. | JavaScript |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int[] values = new int[88];
values[88] = 5; | int[] values = new int[88];
if (88 < values.length) values[88] = 5; | Check bounds. | Java |
let b = 2; b += 1; | let mut b = 2; b += 1; | Need mut to modify. | Rust |
name: message
age: 67 | name: message
age: 67 | Correct. | YAML |
<person age=53> | <person age="53"> | Quote attribute. | XML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
UPDATE users SET email='info' WHERE role=86 | UPDATE users SET email='info' WHERE role=86; | Add semicolon. | SQL |
assert val > 85 | assert val > 85 | Correct. | Python |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
print 'info' | print('info') | print needs parentheses. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
fn bar() -> i32 {{ 26 }} | fn bar() -> i32 {{ 26 }} | Correct. | Rust |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
local a = 65 | local a = 65 | Correct. | Lua |
for (foo in list) | for (foo of list) | for...in iterates keys. | JavaScript |
if a > 73
puts 'data' | if a > 73
puts 'data'
end | Add 'end'. | Ruby |
{{"status":"result" "name":71}} | {{"status":"result", "name":71}} | Add comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.