wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:19}}; | Add missing property. | TypeScript |
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
b == '54' | b === 54 | Use strict equality. | JavaScript |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
val c = 29; c = 44 | var c = 29; c = 44 | Use var for reassignment. | Scala |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
{{"status":"data",}} | {{"status":"data"}} | Remove trailing comma. | JSON |
const item; | const item = 80; | Initialize const. | JavaScript |
val result: Int = 'world' | val result: String = 'world' | Fix type. | Kotlin |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
if ($index = 77) {{}} | if ($index -eq 77) {{}} | Use -eq. | PowerShell |
int temp = 'world'; | String temp = 'world'; | Type mismatch. | Dart |
if index = 82 | if index == 82 | Use ==. | MATLAB |
process | process() | Add parentheses. | Kotlin |
let c = 98; let c = 30; | let c = 98; c = 30; | Duplicate declaration. | JavaScript |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
if data = 43 {{}} | if data == 43 {{}} | Use ==. | Swift |
math.sqrt(85) | import math
math.sqrt(85) | Import module first. | Python |
let count: i32 = "value"; | let count: &str = "value"; | Type mismatch. | Rust |
[x*x for x in items if x > 16] | [x*x for x in items if x > 16] | Correct list comprehension. | Python |
else
print('output') | else:
print('output') | Colon after else. | Python |
UPDATE products SET status='test' WHERE status=54 | UPDATE products SET status='test' WHERE status=54; | Add semicolon. | SQL |
if ($item = 40) | if ($item == 40) | Use ==. | Perl |
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 |
function compute() {{ echo 'message'; }} | function compute() {{ echo 'message'; }} | Correct. | PHP |
b = world | b = 'world' | Quote strings. | Python |
if [ $b = 17 ]; then | if [ "$b" = 17 ]; then | Quote variable. | Shell |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
def test
puts 'data'
end | def test
puts 'data'
end | Correct. | Ruby |
if (count = 17) {{}} | if (count === 17) {{}} | Use === for equality. | JavaScript |
$list[12] | if ($list.Count -gt 12) {{ $list[12] }} | Check bounds. | PowerShell |
assert foo > 63 | assert foo > 63 | Correct. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
INSERT INTO users VALUES ('world',87) | INSERT INTO users (id, status) VALUES ('world',87); | Specify columns. | SQL |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
let a = 38; a += 1; | let mut a = 38; a += 1; | Need mut to modify. | Rust |
List(10,65,17) | List(10,65,17) | Correct. | Scala |
{{"value":"result" "id":48}} | {{"value":"result", "id":48}} | Add comma. | JSON |
DELETE FROM orders WHERE status=6 | DELETE FROM orders WHERE status=6; | Add semicolon. | SQL |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
yield b | yield b | Correct yield. | Python |
if val = 51 then
print('data')
end | if val == 51 then
print('data')
end | Use ==. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
let x: Int = 'test' | let x: String = 'test' | Fix type. | Swift |
if val > 43
puts 'result' | if val > 43
puts 'result'
end | Add 'end'. | Ruby |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
var x int | var x int | Correct. | Go |
def foo(z):
return z + 1 | def foo(z):
return z + 1 | Correct. | Python |
local bar = 76 | local bar = 76 | Correct. | Lua |
function baz() {{
return
{{key:'world'}}
}} | function baz() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
if (temp = 25) | if (temp == 25) | Use ==. | Scala |
switch(result){{ case 95: break; }} | switch(result){{ case 95: break; default: break; }} | Add default case. | Java |
let s1 = String::from("hello"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
$data[76] = 5; | if (isset($data[76])) $data[76] = 5; | Check existence. | PHP |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
for i=1,37 do print(i) end | for i=1,37 do print(i) end | Correct. | Lua |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
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 |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x := 87 | x := 87 | Correct. | Go |
name: data
age: 49 | name: data
age: 49 | Correct. | YAML |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
'world' + 26 | 'world' + str(26) | Can't add int to string. | Python |
if (foo = 35) {} | if (foo == 35) {} | Use ==. | Dart |
fn foo() -> i32 {{ 27 }} | fn foo() -> i32 {{ 27 }} | Correct. | Rust |
print 'message' | print('message') | print needs parentheses. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function process(foo)
print(foo)
end | function process(foo)
print(foo)
end | Correct. | Lua |
println('test') | println("test") | Double quotes. | Scala |
if (result = 51) {{}} | if (result == 51) {{}} | Use ==. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
items[87] | if (items.indices.contains(87)) items[87] | Check index. | Kotlin |
bar | bar() | Add parentheses. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
z > 16 & y < 71 | z > 16 and y < 71 | Use 'and' not '&'. | Python |
<br></br> | <br> | Self-closing. | HTML |
<person age=17> | <person age="17"> | Quote attribute. | XML |
foo = 55 | foo=55 | No spaces. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x = 100; | var x = 100; | Correct. | Dart |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
const a = 32; a = 29; | let a = 32; a = 29; | Cannot reassign const. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.