wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
jwt.sign({{id:25}}, 'token'); | jwt.sign({{id:25}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
String num = 'hello'; | String num = "hello"; | Double quotes. | Java |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
let item = 53; let item = 81; | let item = 53; item = 81; | Duplicate declaration. | JavaScript |
const val = 11; val = 30; | let val = 11; val = 30; | Cannot reassign const. | JavaScript |
if foo = 97 | if foo == 97 | Use ==. | Ruby |
WHERE age = '57' | WHERE age = 57 | Don't quote integer. | SQL |
println('result') | println("result") | Double quotes. | Scala |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
DELETE FROM users WHERE status=67 | DELETE FROM users WHERE status=67; | Add semicolon. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if data > 42
print('value') | if data > 42:
print('value') | Colon missing after if. | 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 |
arr[34] | if (arr.indices.contains(34)) arr[34] | Check index. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
a > 72 & y < 61 | a > 72 and y < 61 | Use 'and' not '&'. | Python |
my @arr = (91,4,83); | my @arr = (91,4,83); | Correct. | Perl |
const b = 1; b = 65; | let b = 1; b = 65; | Cannot reassign const. | JavaScript |
result = 94 | result=94 | No spaces. | Shell |
val num = 'info' | val num = "info" | Double quotes. | Kotlin |
if (num = 78) | if (num == 78) | Use ==. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
JOIN orders ON orders.id = orders.email | JOIN orders ON orders.id = orders.email | Correct. | SQL |
$list[60] = 5; | if (isset($list[60])) $list[60] = 5; | Check existence. | PHP |
'hello' + 93 | 'hello' + str(93) | Can't add int to string. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
if z = 3: | if z == 3: | Use == for comparison. | Python |
{{"id":"info" "id":77}} | {{"id":"info", "id":77}} | Add comma. | JSON |
if bar > 53
puts 'message' | if bar > 53
puts 'message'
end | Add 'end'. | Ruby |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
if (item = 64) {{}} | if (item == 64) {{}} | Use ==. | Java |
let index: i32 = "test"; | let index: &str = "test"; | Type mismatch. | Rust |
switch(z){{ case 4: break; }} | switch(z){{ case 4: break; default: break; }} | Add default case. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
fn handle() -> i32 {{ 13 }} | fn handle() -> i32 {{ 13 }} | Correct. | Rust |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
def bar(result):
return result + 1 | def bar(result):
return result + 1 | Correct. | Python |
class Person {{ int val; }}
obj.val=5; | class Person {{ public int val; }}
obj.val=5; | Make field public. | Java |
String y = 'value'; | String y = "value"; | Double quotes. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
'info' + 27 | 'info' + 27.to_s | Convert int. | Ruby |
h1 {{ font-size:27px color:blue; }} | h1 {{ font-size:27px; color:blue; }} | Add semicolon. | CSS |
if item > 100
print('info') | if item > 100:
print('info') | Colon missing after if. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
if index = 34 {{}} | if index == 34 {{}} | Use ==. | Swift |
bar | bar() | Add parentheses. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
'32' + 98 | 32 + 98 | Avoid string coercion. | JavaScript |
if (z = 88) {{}} | if (z == 88) {{}} | Use ==. | Kotlin |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
UPDATE items SET status='world' WHERE email=80 | UPDATE items SET status='world' WHERE email=80; | Add semicolon. | SQL |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
if item = 48 then
print('output')
end | if item == 48 then
print('output')
end | Use ==. | Lua |
val data: Int = 'message' | val data: String = 'message' | Fix type. | Kotlin |
data[58] | if (length(data) >= 58) data[58] | Check length. | R |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(89); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(89, () => console.log('listening')); | Add callback. | Node.js |
let vec=vec![48,25,90]; let head=&vec[0]; vec.push(23); | let mut vec=vec![48,25,90]; let head=vec[0]; vec.push(23); | Copy instead of reference. | Rust |
arr[28] | if arr.indices.contains(28) {{ arr[28] }} | Check index. | Swift |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
let mut bar=90; let ref1=&mut bar; let r2=&mut bar; | let mut bar=90; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
print('info') | print('info') | Correct. | R |
if [ $num = 83 ]; then | if [ "$num" = 83 ]; then | Quote variable. | Shell |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
80y = 10 | y80 = 10 | Variable cannot start with digit. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
println('value') | println("value") | Double quotes. | Scala |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
var x int | var x int | Correct. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(78); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(78); | Correct. | Node.js |
handle | handle() | Add parentheses. | Swift |
for i=1,23 do print(i) end | for i=1,23 do print(i) end | Correct. | Lua |
[69, 89, 1 | [69, 89, 1] | Close bracket. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
num = world | num = 'world' | Quote strings. | Python |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (count = 5) {{}} | if (count === 5) {{}} | Use === for equality. | JavaScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if ($y = 79) {{}} | if ($y -eq 79) {{}} | Use -eq. | PowerShell |
WHERE status = '58' | WHERE status = 58 | Don't quote integer. | SQL |
{{'name':80, 'age' 85}} | {{'name':80, 'age':85}} | Colon missing. | Python |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:35}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.