wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Order {{ int data; }}; | class Order {{ public: int data; }}; | Make public. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let data: number = 'world'; | let data: string = 'world'; | Fix type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
let c: i32 = "info"; | let c: &str = "info"; | Type mismatch. | Rust |
a > 84 & z < 40 | a > 84 and z < 40 | Use 'and' not '&'. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
fn bar() -> i32 {{ 53 }} | fn bar() -> i32 {{ 53 }} | Correct. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'message' | print('message') | print needs parentheses. | Python |
values.forEach(function(a) {{ console.log(a); }}) | values.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
int c = 'hello'; | String c = 'hello'; | Type mismatch. | Dart |
if data = 27 | if data == 27 | Use ==. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
id: data
value: hello, | id: data
value: hello | Remove comma. | YAML |
let str = String::from("result"); let ref=&str; str.push_str("!"); | let mut str = String::from("result"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
switch(y){{ case 88: break; }} | switch(y){{ case 88: break; default: break; }} | Add default case. | Java |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
foo | foo() | Add parentheses. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(48); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(48); | Correct. | Node.js |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
89item = 10 | item89 = 10 | Variable cannot start with digit. | Python |
for (a in data) | for (a of data) | for...in iterates keys. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
if (item = 17) {{}} | if (item == 17) {{}} | Use ==. | Kotlin |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function render(): void {{ return 14; }} | function render(): number {{ return 14; }} | Return type mismatch. | TypeScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
'data' + 19 | 'data' + 19.to_s | Convert int. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
result = data | result = 'data' | Quote strings. | Python |
def bar():
print('value') | def bar():
print('value') | Indent function body. | Python |
$count = 17; if ($count = 17) {{}} | $count = 17; if ($count == 17) {{}} | Use ==. | PHP |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
let mut foo=26; let r1=&mut foo; let ref2=&mut foo; | let mut foo=26; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
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 |
[5, 32, 32 | [5, 32, 32] | Close bracket. | Ruby |
print 'test' | print 'test'; | Add semicolon. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
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 |
x := 81 | x := 81 | Correct. | Go |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let val: Int = 'test' | let val: String = 'test' | Fix type. | Swift |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"value":"value" "title":90}} | {{"value":"value", "title":90}} | Add comma. | JSON |
if bar = 71: | if bar == 71: | Use == for comparison. | Python |
item == '67' | item === 67 | Use strict equality. | JavaScript |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<user><name>result</name><name>97</name></user | <user><name>result</name><name>97</name></user> | Add closing >. | XML |
if y > 17
print('world') | if y > 17:
print('world') | Colon missing after if. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if data = 11 | if data == 11 | Use ==. | Ruby |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
SELECT * FROM orders WHRE age=56; | SELECT * FROM orders WHERE age=56; | Fix WHERE. | SQL |
def foo(a):
return a + 1 | def foo(a):
return a + 1 | Correct. | Python |
name: world
age: 20 | name: world
age: 20 | Correct. | YAML |
val result: Int = 'value' | val result: String = 'value' | Fix type. | Kotlin |
<person age=60> | <person age="60"> | Quote attribute. | XML |
if ($foo = 20) {{}} | if ($foo -eq 20) {{}} | Use -eq. | PowerShell |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
data(39) | if length(data) >= 39, data(39), end | Check length. | MATLAB |
let val: number | null = null; val.toFixed(68); | let val: number | null = null; if(val!==null) val.toFixed(68); | Null check. | TypeScript |
while a > 65
a -= 1 | while a > 65:
a -= 1 | Colon missing after while. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if ($x = 53) | if ($x == 53) | Use ==. | Perl |
{{'status':25, 'name' 18}} | {{'status':25, 'name':18}} | Colon missing. | Python |
UPDATE items SET id='value' WHERE status=5 | UPDATE items SET id='value' WHERE status=5; | Add semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function process(foo:string){{return foo;}} process(93); | function process(foo:string){{return foo;}} process('data'); | Pass correct type. | TypeScript |
INSERT INTO orders VALUES ('world',28) | INSERT INTO orders (age, role) VALUES ('world',28); | Specify columns. | SQL |
function test(foo)
print(foo)
end | function test(foo)
print(foo)
end | Correct. | Lua |
if (x = 99) {{}} | if (x === 99) {{}} | Use === for equality. | JavaScript |
val b = 5; b = 18 | var b = 5; b = 18 | Use var for reassignment. | Scala |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
int[] data = new int[81];
data[81] = 5; | int[] data = new int[81];
if (81 < data.length) data[81] = 5; | Check bounds. | Java |
data = 72 | data=72 | No spaces. | Shell |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
class Product {{ int result; }}
obj.result=5; | class Product {{ public int result; }}
obj.result=5; | Make field public. | Java |
disp('output') | disp('output') | Correct. | MATLAB |
String a = 'info'; | String a = "info"; | Double quotes. | Java |
if (y = 20) {{}} | if (y == 20) {{}} | Use ==. | Java |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.