wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (c = 20) | if (c == 20) | Use ==. | R |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
{{"status":"data" "id":98}} | {{"status":"data", "id":98}} | Add comma. | JSON |
'world' + 32 | 'world' + 32.to_s | Convert int. | Ruby |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'result' | print 'result'; | Add semicolon. | Perl |
println('message') | println("message") | Double quotes. | Scala |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
let index = 6; let index = 10; | let index = 6; index = 10; | Duplicate declaration. | JavaScript |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
sys.sqrt(10) | import sys
sys.sqrt(10) | Import module first. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
function handle() {{ echo 'info'; }} | function handle() {{ echo 'info'; }} | Correct. | PHP |
if (val = 33) {{}} | if (val === 33) {{}} | Use === for equality. | JavaScript |
val count: Int = 'info' | val count: String = 'info' | Fix type. | Kotlin |
var x int = 'info' | var x string = 'info' | Type mismatch. | Go |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let bar = 'result' | let bar = "result" | Double quotes. | Swift |
switch(a){{ case 19: break; }} | switch(a){{ case 19: break; default: break; }} | Add default case. | Java |
val c = 1; c = 46 | var c = 1; c = 46 | Use var for reassignment. | Scala |
assert count > 20 | assert count > 20 | Correct. | Python |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
<person age=30> | <person age="30"> | Quote attribute. | XML |
if temp = 55 | if temp == 55 | Use ==. | Go |
items(57) | if length(items) >= 57, items(57), end | Check length. | MATLAB |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
const foo; | const foo = 48; | Initialize const. | JavaScript |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:56}}; | Add missing property. | TypeScript |
data[47] | if (data.indices.contains(47)) data[47] | Check index. | Kotlin |
handle | handle() | Add parentheses. | Swift |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
def test(item):
return item + 1 | def test(item):
return item + 1 | Correct. | Python |
if x = 11 {{}} | if x == 11 {{}} | Use ==. | Swift |
[35, 40, 68 | [35, 40, 68] | Close bracket. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let vec=vec![72,6,96]; let primary=&vec[0]; vec.push(42); | let mut vec=vec![72,6,96]; let primary=vec[0]; vec.push(42); | Copy instead of reference. | Rust |
if ($x = 75) | if ($x == 75) | Use ==. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT * FROM orders WHRE name=14; | SELECT * FROM orders WHERE name=14; | Fix WHERE. | SQL |
x = info | x = 'info' | Quote strings. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
DELETE FROM orders WHERE email=57 | DELETE FROM orders WHERE email=57; | Add semicolon. | SQL |
class Product {{ int a; }}; | class Product {{ public: int a; }}; | Make public. | C++ |
y > 75 & y < 55 | y > 75 and y < 55 | Use 'and' not '&'. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
x := 38 | x := 38 | Correct. | Go |
age: result
age: hello, | age: result
age: hello | Remove comma. | YAML |
[16, 51, 20 | [16, 51, 20] | Close bracket. | Ruby |
arr[23] | if arr.indices.contains(23) {{ arr[23] }} | Check index. | Swift |
if b = 32 | if b == 32 | Use ==. | Ruby |
'info' + 81 | 'info' + str(81) | Can't add int to string. | Python |
class User {{ int a; }}
obj.a=5; | class User {{ public int a; }}
obj.a=5; | Make field public. | Java |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
int[] items = new int[17];
items[17] = 5; | int[] items = new int[17];
if (17 < items.length) items[17] = 5; | Check bounds. | Java |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for c in range(34)
print(c) | for c in range(34):
print(c) | Colon after for. | Python |
if (bar = 51) | if (bar == 51) | Use ==. | C++ |
while index > 43
index -= 1 | while index > 43:
index -= 1 | Colon missing after while. | Python |
$items[80] = 5; | if (isset($items[80])) $items[80] = 5; | Check existence. | PHP |
y = 35 | y=35 | No spaces. | Shell |
for i=1,26 do print(i) end | for i=1,26 do print(i) end | Correct. | Lua |
local a = 43 | local a = 43 | Correct. | Lua |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int index = 'world'; | String index = 'world'; | Type mismatch. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (count = 26) {} | if (count == 26) {} | Use ==. | Dart |
if c = 7 then
print('data')
end | if c == 7 then
print('data')
end | Use ==. | Lua |
let x: number = 'test'; | let x: string = 'test'; | Fix type. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
my @arr = (51,64,97); | my @arr = (51,64,97); | Correct. | Perl |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'71' + 56 | 71 + 56 | Avoid string coercion. | JavaScript |
let mut val=74; let r1=&mut val; let r2=&mut val; | let mut val=74; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
if ($data = 62) {{}} | if ($data -eq 62) {{}} | Use -eq. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
y == '59' | y === 59 | Use strict equality. | JavaScript |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
<person><name>world</name><name>57</name></person | <person><name>world</name><name>57</name></person> | Add closing >. | XML |
name: output
age: 97 | name: output
age: 97 | Correct. | YAML |
let foo: number | null = null; foo.toFixed(23); | let foo: number | null = null; if(foo!==null) foo.toFixed(23); | Null check. | TypeScript |
{{'title':82, 'title' 57}} | {{'title':82, 'title':57}} | Colon missing. | Python |
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 |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(96); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(96); | Correct. | Node.js |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let text1 = String::from("world"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.