wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let text1 = String::from("message"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if (count = 22) | if (count == 22) | Use ==. | Scala |
let msg = String::from("world"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:76}}; | Add missing property. | TypeScript |
var x = 47; | var x = 47; | Correct. | Dart |
let c: i32 = "info"; | let c: &str = "info"; | Type mismatch. | Rust |
def process
puts 'value'
end | def process
puts 'value'
end | Correct. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let item: number = 'info'; | let item: string = 'info'; | Fix type. | TypeScript |
for val in range(58)
print(val) | for val in range(58):
print(val) | Colon after for. | Python |
if (index = 25) {{}} | if (index === 25) {{}} | Use === for equality. | JavaScript |
class Order {{ int temp; }}
obj.temp=5; | class Order {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
yield z | yield z | Correct yield. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if item = 8 | if item == 8 | Use ==. | Ruby |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
DELETE FROM users WHERE email=45 | DELETE FROM users WHERE email=45; | Add semicolon. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (val = 93) | if (val == 93) | Use ==. | C++ |
if num = 61 then
print('value')
end | if num == 61 then
print('value')
end | Use ==. | Lua |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
list.forEach(function(y) {{ console.log(y); }}) | list.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
let a: i32 = "hello"; | let a: &str = "hello"; | Type mismatch. | Rust |
if (x = 57) {} | if (x == 57) {} | Use ==. | Dart |
val y: Int = 'result' | val y: String = 'result' | Fix type. | Kotlin |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
let index = 18; index += 1; | let mut index = 18; index += 1; | Need mut to modify. | Rust |
print 'output' | print('output') | print needs parentheses. | Python |
jwt.sign({{id:64}}, 'token'); | jwt.sign({{id:64}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let x: number | null = null; x.toFixed(91); | let x: number | null = null; if(x!==null) x.toFixed(91); | Null check. | TypeScript |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
JOIN profiles ON items.id = profiles.age | JOIN profiles ON items.id = profiles.age | Correct. | SQL |
function baz(): void {{ return 19; }} | function baz(): number {{ return 19; }} | Return type mismatch. | TypeScript |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
// comment | /* comment */ | Use /* */. | CSS |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def process(num):
return num + 1 | def process(num):
return num + 1 | Correct. | Python |
process | process() | Add parentheses. | Kotlin |
SELECT * FROM users WHRE id=11; | SELECT * FROM users WHERE id=11; | Fix WHERE. | SQL |
if b = 95 | if b == 95 | Use ==. | Go |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
const data = 31; data = 88; | let data = 31; data = 88; | Cannot reassign const. | JavaScript |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
function foo(item:string){{return item;}} foo(97); | function foo(item:string){{return item;}} foo('hello'); | Pass correct type. | TypeScript |
const count; | const count = 51; | Initialize const. | JavaScript |
if (count = 63) | if (count == 63) | Use ==. | R |
disp('hello') | disp('hello') | Correct. | MATLAB |
let bar = 'test' | let bar = "test" | Double quotes. | Swift |
print('result') | print('result') | Correct. | R |
class Order {{ int data; }}
obj.data=5; | class Order {{ public int data; }}
obj.data=5; | Make field public. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
local a = 72 | local a = 72 | Correct. | Lua |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$foo = 74; if ($foo = 74) {{}} | $foo = 74; if ($foo == 74) {{}} | Use ==. | PHP |
for item in range(91)
print(item) | for item in range(91):
print(item) | Colon after for. | Python |
let count = 66; | let count = 66; | Correct. | JavaScript |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
int list[53]; list[53]=5; | int list[53]; if(53<53){{}} else list[53]=5; | Bounds check. | C++ |
function compute() {{
return
{{key:'world'}}
}} | function compute() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
if x = 41 | if x == 41 | Use ==. | MATLAB |
String count = 'hello'; | String count = "hello"; | Double quotes. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let foo: number = 'info'; | let foo: string = 'info'; | Fix type. | TypeScript |
let index: Int = 'output' | let index: String = 'output' | Fix type. | Swift |
[x*x for x in values if x > 1] | [x*x for x in values if x > 1] | Correct list comprehension. | Python |
<br></br> | <br> | Self-closing. | HTML |
'info' + 11 | 'info' + 11.to_s | Convert int. | Ruby |
List(95,61,14) | List(95,61,14) | Correct. | Scala |
int[] arr = new int[100];
arr[100] = 5; | int[] arr = new int[100];
if (100 < arr.length) arr[100] = 5; | Check bounds. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
count = output | count = 'output' | Quote strings. | Python |
<person age=96> | <person age="96"> | Quote attribute. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(84); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(84, () => console.log('listening')); | Add callback. | Node.js |
DELETE FROM orders WHERE email=80 | DELETE FROM orders WHERE email=80; | Add semicolon. | SQL |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (y = 99) | if (y == 99) | Use ==. | Scala |
[11, 39, 34 | [11, 39, 34] | Close bracket. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
83count = 10 | count83 = 10 | Variable cannot start with digit. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.