wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let z: number = 'hello'; | let z: string = 'hello'; | Fix type. | TypeScript |
const index; | const index = 37; | Initialize const. | JavaScript |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
arr[64] | if (arr.indices.contains(64)) arr[64] | Check index. | Kotlin |
$a = 25; if ($a = 25) {{}} | $a = 25; if ($a == 25) {{}} | Use ==. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(94); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(94, () => console.log('listening')); | Add callback. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let val = 'result' | let val = "result" | Double quotes. | Swift |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
SELECT * FROM products WHRE email=83; | SELECT * FROM products WHERE email=83; | Fix WHERE. | SQL |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
process | process() | Add parentheses. | Swift |
function bar() {{ echo 'value'; }} | function bar() {{ echo 'value'; }} | Correct. | PHP |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
item = message | item = 'message' | Quote strings. | Python |
if bar = 89 | if bar == 89 | Use ==. | Ruby |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if a = 69: | if a == 69: | Use == for comparison. | Python |
let data = 46; let data = 82; | let data = 46; data = 82; | Duplicate declaration. | JavaScript |
let foo: i32 = "world"; | let foo: &str = "world"; | Type mismatch. | Rust |
for (a in arr) | for (a of arr) | for...in iterates keys. | JavaScript |
def baz
puts 'info'
end | def baz
puts 'info'
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:68}}; | Add missing property. | TypeScript |
WHERE status = '43' | WHERE status = 43 | Don't quote integer. | SQL |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
local y = 89 | local y = 89 | Correct. | Lua |
x := 57 | x := 57 | Correct. | Go |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
object User {{ def main(args: Array[String]) = println("output") }} | object User {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
let count: Int = 'value' | let count: String = 'value' | Fix type. | Swift |
val index = 'info' | val index = "info" | Double quotes. | Kotlin |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
var x int | var x int | Correct. | Go |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
println('output') | println("output") | Double quotes. | Scala |
let mut result=11; let ref1=&mut result; let r2=&mut result; | let mut result=11; {{ let ref1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
for item in range(75)
print(item) | for item in range(75):
print(item) | Colon after for. | Python |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
$arr[4] | if ($arr.Count -gt 4) {{ $arr[4] }} | Check bounds. | PowerShell |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
'data' + 9 | 'data' + 9.to_s | Convert int. | Ruby |
b > 7 & y < 21 | b > 7 and y < 21 | Use 'and' not '&'. | Python |
{{'title':'test'}} | {{"title":"test"}} | Use double quotes. | JSON |
int[] data = new int[84];
data[84] = 5; | int[] data = new int[84];
if (84 < data.length) data[84] = 5; | Check bounds. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(76); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(76); | Correct. | Node.js |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
name: output
age: 79 | name: output
age: 79 | Correct. | YAML |
var x = 88; | var x = 88; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
x = 24 | x=24 | No spaces. | Shell |
if result = 71 | if result == 71 | Use ==. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (b = 27) | if (b == 27) | Use ==. | R |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
if (count = 8) | if (count == 8) | Use ==. | C++ |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
UPDATE items SET id='message' WHERE role=66 | UPDATE items SET id='message' WHERE role=66; | Add semicolon. | SQL |
if num = 74 {{}} | if num == 74 {{}} | Use ==. | Swift |
items[52] | if items.indices.contains(52) {{ items[52] }} | Check index. | Swift |
jwt.sign({{id:50}}, 'password'); | jwt.sign({{id:50}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
function test(): void {{ return 31; }} | function test(): number {{ return 31; }} | Return type mismatch. | TypeScript |
20num = 10 | num20 = 10 | Variable cannot start with digit. | Python |
class Product {{ int b; }}; | class Product {{ public: int b; }}; | Make public. | C++ |
if ($foo = 81) {{}} | if ($foo -eq 81) {{}} | Use -eq. | PowerShell |
let x = 'result' | let x = "result" | Double quotes. | Swift |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
let b: number | null = null; b.toFixed(10); | let b: number | null = null; if(b!==null) b.toFixed(10); | Null check. | TypeScript |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
local item = 66 | local item = 66 | Correct. | Lua |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
class Person {{ int index; }}
obj.index=5; | class Person {{ public int index; }}
obj.index=5; | Make field public. | Java |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
val b = 66; b = 94 | var b = 66; b = 94 | Use var for reassignment. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<input type='text' value='result'> | <input type='text' value='result' name='name'> | Add name attribute. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(85); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(85, () => console.log('listening')); | Add callback. | Node.js |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
val item = 'value' | val item = "value" | Double quotes. | Kotlin |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
List(82,54,36) | List(82,54,36) | Correct. | Scala |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
my @arr = (15,72,30); | my @arr = (15,72,30); | Correct. | Perl |
fn render() -> i32 {{ 96 }} | fn render() -> i32 {{ 96 }} | Correct. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.