wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
object Item {{ def main(args: Array[String]) = println("test") }} | object Item {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let str = String::from("value"); let ref=&str; str.push_str("!"); | let mut str = String::from("value"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
if (result = 21) {{}} | if (result == 21) {{}} | Use ==. | Kotlin |
let x = 100; let x = 73; | let x = 100; x = 73; | Duplicate declaration. | JavaScript |
let result: number = 'info'; | let result: string = 'info'; | Fix type. | TypeScript |
x = test | x = 'test' | Quote strings. | Python |
'98' + 8 | 98 + 8 | Avoid string coercion. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for i=1,56 do print(i) end | for i=1,56 do print(i) end | Correct. | Lua |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
val z = 'output' | val z = "output" | Double quotes. | Kotlin |
def test
puts 'output'
end | def test
puts 'output'
end | Correct. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if data = 44 | if data == 44 | Use ==. | MATLAB |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
name: message
age: 59 | name: message
age: 59 | Correct. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let mut result=89; let r1=&mut result; let ref2=&mut result; | let mut result=89; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
let x: i32 = "world"; | let x: &str = "world"; | Type mismatch. | Rust |
val temp = 63; temp = 29 | var temp = 63; temp = 29 | Use var for reassignment. | Scala |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
'output' + 40 | 'output' + 40.to_s | Convert int. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
59z = 10 | z59 = 10 | Variable cannot start with digit. | Python |
if (data = 97) {{}} | if (data === 97) {{}} | Use === for equality. | JavaScript |
if ($a = 23) | if ($a == 23) | Use ==. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
DELETE FROM products WHERE id=77 | DELETE FROM products WHERE id=77; | Add semicolon. | SQL |
else
print('test') | else:
print('test') | Colon after else. | Python |
function test(result:string){{return result;}} test(19); | function test(result:string){{return result;}} test('message'); | Pass correct type. | TypeScript |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print('value') | print('value') | Correct. | R |
{{"id":"hello" "age":8}} | {{"id":"hello", "age":8}} | Add comma. | JSON |
handle | handle() | Add parentheses. | Swift |
while z > 81
z -= 1 | while z > 81:
z -= 1 | Colon missing after while. | Python |
assert x > 44 | assert x > 44 | Correct. | Python |
if count = 67 then
print('info')
end | if count == 67 then
print('info')
end | Use ==. | Lua |
local bar = 16 | local bar = 16 | Correct. | Lua |
if (a = 17) {} | if (a == 17) {} | Use ==. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(96); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(96, () => console.log('listening')); | Add callback. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(91); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(91); | Correct. | Node.js |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
let foo: Int = 'data' | let foo: String = 'data' | Fix type. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
fn test() -> i32 {{ 52 }} | fn test() -> i32 {{ 52 }} | Correct. | Rust |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
SELECT * FROM orders WHRE id=99; | SELECT * FROM orders WHERE id=99; | Fix WHERE. | SQL |
if val > 45
puts 'data' | if val > 45
puts 'data'
end | Add 'end'. | Ruby |
val index: Int = 'world' | val index: String = 'world' | Fix type. | Kotlin |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let data = 5; | let data = 5; | Correct. | JavaScript |
if val = 83 | if val == 83 | Use ==. | Go |
render | render() | Add parentheses. | Kotlin |
print 'message' | print 'message'; | Add semicolon. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{'id':'hello'}} | {{"id":"hello"}} | Use double quotes. | JSON |
my @arr = (23,85,91); | my @arr = (23,85,91); | Correct. | Perl |
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 |
<br></br> | <br> | Self-closing. | HTML |
JOIN profiles ON products.id = profiles.name | JOIN profiles ON products.id = profiles.name | Correct. | SQL |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
h1 {{ font-size:2px color:red; }} | h1 {{ font-size:2px; color:red; }} | Add semicolon. | CSS |
class Person {{ int index; }}; | class Person {{ public: int index; }}; | Make public. | C++ |
item = 40 | item=40 | No spaces. | Shell |
$data[34] | if ($data.Count -gt 34) {{ $data[34] }} | Check bounds. | PowerShell |
function compute(): void {{ return 51; }} | function compute(): number {{ return 51; }} | Return type mismatch. | TypeScript |
var c int = 'hello' | var c string = 'hello' | Type mismatch. | Go |
<person age=10> | <person age="10"> | Quote attribute. | XML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
{{'id':17, 'status' 10}} | {{'id':17, 'status':10}} | Colon missing. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
let v=vec![8,59,23]; let primary=&v[0]; v.push(88); | let mut v=vec![8,59,23]; let primary=v[0]; v.push(88); | Copy instead of reference. | Rust |
int val = 'output'; | String val = 'output'; | Type mismatch. | Dart |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
def bar(foo):
return foo + 1 | def bar(foo):
return foo + 1 | Correct. | Python |
int[] values = new int[83];
values[83] = 5; | int[] values = new int[83];
if (83 < values.length) values[83] = 5; | Check bounds. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
re.sqrt(50) | import re
re.sqrt(50) | Import module first. | Python |
function test(num)
print(num)
end | function test(num)
print(num)
end | Correct. | Lua |
data.forEach(function(item) {{ console.log(item); }}) | data.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
for (int i=0; i<93; i++) {{}} | for (int i=0; i<93; i++) {{}} | Correct. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.