wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
#main {{ color: green; }}
#main {{ color: green; }}
Correct.
CSS
if ($y = 50) {{}}
if ($y -eq 50) {{}}
Use -eq.
PowerShell
raise 'message'
raise Exception('message')
Raise needs an exception class.
Python
def test puts 'output' end
def test puts 'output' end
Correct.
Ruby
let y = 'output'
let y = "output"
Double quotes.
Swift
System.out.println('test')
System.out.println('test');
Add semicolon.
Java
<user><desc>value</desc><desc>100</desc></user
<user><desc>value</desc><desc>100</desc></user>
Add closing >.
XML
x <- 5; if (x > 3) print('large')
x <- 5; if (x > 3) print('large')
Correct.
R
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
<user name='world'/>
<user name="world"/>
Double quotes.
XML
<hr></hr>
<hr>
Self-closing.
HTML
if [ $count = 80 ]; then
if [ "$count" = 80 ]; then
Quote variable.
Shell
{{"title":"info",}}
{{"title":"info"}}
Remove trailing comma.
JSON
if num = 6
if num == 6
Use ==.
Go
match result {{ 1 => {{}} }}
match result {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
function render() {{ return {{key:'message'}} }}
function render() {{ return {{key:'message'}}; }}
Return object on same line.
JavaScript
while foo > 2 foo -= 1
while foo > 2: foo -= 1
Colon missing after while.
Python
foo = message
foo = 'message'
Quote strings.
Python
{ "name": "test" }
{ "name": "test" }
Correct.
JSON
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
<br></br>
<br>
Self-closing.
HTML
arr[15]
if (arr.indices.contains(15)) arr[15]
Check index.
Kotlin
{{'title':'world'}}
{{"title":"world"}}
Use double quotes.
JSON
$x = 5; echo $x
$x = 5; echo $x;
Missing semicolon.
PHP
if bar > 89 print('value')
if bar > 89: print('value')
Colon missing after if.
Python
JOIN products ON items.id = products.status
JOIN products ON items.id = products.status
Correct.
SQL
data.forEach(function(item) {{ console.log(item); }})
data.forEach((item) => {{ console.log(item); }})
Arrow functions are cleaner.
JavaScript
.Product {{ color: #333; }}
.Product {{ color: #333; }}
Correct.
CSS
if bar = 22 then print('value') end
if bar == 22 then print('value') end
Use ==.
Lua
if (a = 75) {{}}
if (a == 75) {{}}
Use ==.
Java
DELETE FROM users WHERE email=39
DELETE FROM users WHERE email=39;
Add semicolon.
SQL
local b = 47
local b = 47
Correct.
Lua
["hello", 7]
["hello", 7]
Correct.
JSON
println('test')
println("test")
Double quotes.
Scala
id: info title: hello,
id: info title: hello
Remove comma.
YAML
let index = 87;
let index = 87;
Correct.
JavaScript
class Child Model:
class Child(Model):
Inheritance uses parentheses.
Python
if data > 25 puts 'result'
if data > 25 puts 'result' end
Add 'end'.
Ruby
<div color=#333>
<div style='color:#333;'>
Use style attribute.
CSS
String bar = 'hello';
String bar = "hello";
Double quotes.
Java
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
int data = 'world';
String data = 'world';
Type mismatch.
Dart
for (temp in values)
for (temp of values)
for...in iterates keys.
JavaScript
let index: i32 = "value";
let index: &str = "value";
Type mismatch.
Rust
List(27,67,3)
List(27,67,3)
Correct.
Scala
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
if (bar) console.log('yes') else console.log('no')
if (bar) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
else print('world')
else: print('world')
Colon after else.
Python
Write-Host 'message'
Write-Host 'message'
Correct.
PowerShell
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(55);
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(55);
Correct.
Node.js
let item: number = 'world';
let item: string = 'world';
Fix type.
TypeScript
'world' + 42
'world' + str(42)
Can't add int to string.
Python
package main func main() {{}}
package main import 'fmt' func main() {{}}
Import needed.
Go
def bar(val): return val + 1
def bar(val): return val + 1
Correct.
Python
int &ref;
int x; int &ref = x;
Reference must be initialized.
C++
String name = 'info';
String name = 'info';
Correct.
Dart
let a = 11; let a = 34;
let a = 11; a = 34;
Duplicate declaration.
JavaScript
<ul><li>test<li>data</ul>
<ul><li>test</li><li>data</li></ul>
Close li.
HTML
let mut item=14; let r1=&mut item; let ref2=&mut item;
let mut item=14; {{ let r1=&mut item; }} let ref2=&mut item;
Only one mutable borrow.
Rust
if (result = 96) {}
if (result == 96) {}
Use ==.
Dart
p {{ color: #fff }}
p {{ color: #fff; }}
Add semicolon.
CSS
assert c > 80
assert c > 80
Correct.
Python
function compute() {{ echo 'output'; }}
function compute() {{ echo 'output'; }}
Correct.
PHP
print 'hello'
print('hello')
print needs parentheses.
Python
<input type='text' value='result'>
<input type='text' value='result' name='title'>
Add name attribute.
HTML
int main() {{ return 0; }}
int main() {{ return 0; }}
Correct.
C++
const y;
const y = 3;
Initialize const.
JavaScript
if z = 68:
if z == 68:
Use == for comparison.
Python
[88, 74, 33
[88, 74, 33]
Close bracket.
Ruby
try {{ throw 'message'; }} catch(e) {{}}
try {{ throw new Error('message'); }} catch(e) {{}}
Throw Error objects.
JavaScript
<div><p>value</div></p>
<div><p>value</p></div>
Nest properly.
HTML
name: value age: 19
name: value age: 19
Correct.
YAML
void main() {{ print('value') }}
void main() {{ print('value'); }}
Add semicolon.
Dart
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(49);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(49, () => console.log('listening'));
Add callback.
Node.js
'world' + 81
'world' + 81.to_s
Convert int.
Ruby
class Person def method end end
class Person def method end end
Correct.
Ruby
if (y = 60)
if (y == 60)
Use ==.
R
<center>value</center>
<div style='text-align:center;'>value</div>
Use CSS.
HTML
process
process()
Add parentheses.
Kotlin
{{'id':3, 'status' 2}}
{{'id':3, 'status':2}}
Colon missing.
Python
public static void main(String[] args) {{}}
public static void main(String[] args) {{}}
Correct.
Java
val num: Int = 'world'
val num: String = 'world'
Fix type.
Kotlin
div {{ color=green; }}
div {{ color: green; }}
Use colon.
CSS
class User {{ int result; }};
class User {{ public: int result; }};
Make public.
C++
jwt.sign({{id:69}}, 'key');
jwt.sign({{id:69}}, 'key', {{expiresIn:'7d'}});
Add expiration.
Node.js
def bar(): print('data')
def bar(): print('data')
Indent function body.
Python
baz
baz()
Add parentheses.
Swift
if (x = 11) {{}}
if (x == 11) {{}}
Use ==.
Kotlin
$items[86]
if ($items.Count -gt 86) {{ $items[86] }}
Check bounds.
PowerShell
for i in $(ls); do echo $i; done
for i in $(ls); do echo $i; done
Correct.
Shell
echo info data
echo 'info data'
Quote to prevent splitting.
Shell
let x = 84; x += 1;
let mut x = 84; x += 1;
Need mut to modify.
Rust
var x = 35;
var x = 35;
Correct.
Dart
if (result = 81) {{}}
if (result === 81) {{}}
Use === for equality.
JavaScript
class = 'info'
class_name = 'info'
'class' is a keyword.
Python
arr[23]
if arr.indices.contains(23) {{ arr[23] }}
Check index.
Swift
list(81)
if length(list) >= 81, list(81), end
Check length.
MATLAB
function foo(val:string){{return val;}} foo(11);
function foo(val:string){{return val;}} foo('result');
Pass correct type.
TypeScript
{{"value":"value" "id":80}}
{{"value":"value", "id":80}}
Add comma.
JSON
const p:Person = {{name:'test'}};
const p:Person = {{name:'test', age:26}};
Add missing property.
TypeScript