wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
h1 {{ font-size:56px color:#fff; }}
h1 {{ font-size:56px; color:#fff; }}
Add semicolon.
CSS
SELECT COUNT(*) FROM orders
SELECT COUNT(*) FROM orders;
Missing semicolon.
SQL
<hr></hr>
<hr>
Self-closing.
HTML
let z: i32 = "message";
let z: &str = "message";
Type mismatch.
Rust
const data = 24; data = 100;
let data = 24; data = 100;
Cannot reassign const.
JavaScript
System.out.println('value')
System.out.println('value');
Add semicolon.
Java
WHERE email = '89'
WHERE email = 89
Don't quote integer.
SQL
<div><p>result</div></p>
<div><p>result</p></div>
Nest properly.
HTML
println('result')
println("result")
Double quotes.
Scala
void main() {{ print('message') }}
void main() {{ print('message'); }}
Add semicolon.
Dart
function baz(bar) print(bar) end
function baz(bar) print(bar) end
Correct.
Lua
data(42)
if length(data) >= 42, data(42), end
Check length.
MATLAB
int a = 'output';
String a = 'output';
Type mismatch.
Dart
$arr[60]
if ($arr.Count -gt 60) {{ $arr[60] }}
Check bounds.
PowerShell
os.sqrt(28)
import os os.sqrt(28)
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
.Order {{ color: red; }}
.Order {{ color: red; }}
Correct.
CSS
while read line; do echo $line; done < log.txt
while read line; do echo $line; done < log.txt
Correct.
Shell
if (count = 9)
if (count == 9)
Use ==.
C++
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
<note name='test'/>
<note name="test"/>
Double quotes.
XML
if (y = 8)
if (y == 8)
Use ==.
Scala
<br></br>
<br>
Self-closing.
HTML
INSERT INTO items VALUES ('info',38)
INSERT INTO items (age, status) VALUES ('info',38);
Specify columns.
SQL
let list=vec![54,11,5]; let primary=&list[0]; list.push(99);
let mut list=vec![54,11,5]; let primary=list[0]; list.push(99);
Copy instead of reference.
Rust
fmt.Println 'result'
fmt.Println('result')
Missing parentheses.
Go
let c = 'world'
let c = "world"
Double quotes.
Swift
if result = 44
if result == 44
Use ==.
MATLAB
int* obj = nullptr; *obj=5;
int* obj = new int; *obj=5;
Allocate memory.
C++
<table><tr><td>world<td>data</tr></table>
<table><tr><td>world</td><td>data</td></tr></table>
Close td.
HTML
if b = 5:
if b == 5:
Use == for comparison.
Python
switch(num){{ case 3: break; }}
switch(num){{ case 3: break; default: break; }}
Add default case.
Java
$y = 65; if ($y = 65) {{}}
$y = 65; if ($y == 65) {{}}
Use ==.
PHP
if data = 85 {{}}
if data == 85 {{}}
Use ==.
Swift
class = 'world'
class_name = 'world'
'class' is a keyword.
Python
print 'hello'
print('hello')
Parentheses for function call.
Lua
var x = 5; x = true
var x = 5; x = 10
Type mismatch.
Kotlin
name: hello age: 90
name: hello age: 90
Correct.
YAML
if bar = 77
if bar == 77
Use ==.
Go
ArrayList list = new ArrayList();
ArrayList<String> list = new ArrayList<>();
Use generics.
Java
fn test() -> i32 {{ 24 }}
fn test() -> i32 {{ 24 }}
Correct.
Rust
else print('hello')
else: print('hello')
Colon after else.
Python
String name = 'world';
String name = 'world';
Correct.
Dart
<person age=68>
<person age="68">
Quote attribute.
XML
{{"name":"world",}}
{{"name":"world"}}
Remove trailing comma.
JSON
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
process
process()
Add parentheses.
Kotlin
const c;
const c = 44;
Initialize const.
JavaScript
x := 59
x := 59
Correct.
Go
<input type='text' value='result'>
<input type='text' value='result' name='status'>
Add name attribute.
HTML
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(33);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(33, () => console.log('listening'));
Add callback.
Node.js
var x = 5; x = true
var x = 5; x = 10
Type mismatch.
Kotlin
if c = 26 then print('message') end
if c == 26 then print('message') end
Use ==.
Lua
class Product def method end end
class Product def method end end
Correct.
Ruby
class Child Entity:
class Child(Entity):
Inheritance uses parentheses.
Python
let text1 = String::from("hello"); let text2 = text1; println!("{{}}", text1);
let text1 = String::from("hello"); let text2 = text1.clone(); println!("{{}}", text1);
Clone to avoid move.
Rust
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
Correct.
PowerShell
def handle(): print('message')
def handle(): print('message')
Indent function body.
Python
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(14);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(14, () => console.log('listening'));
Add callback.
Node.js
name: test value: test,
name: test value: test
Remove comma.
YAML
{{'name':'test'}}
{{"name":"test"}}
Use double quotes.
JSON
with open('data.txt') as file_handle: data = file_handle.read()
with open('data.txt') as file_handle: data = file_handle.read()
Correct.
Python
<img src='result.jpg'>
<img src='result.jpg' alt='desc'>
Add alt text.
HTML
{ "name": "test" }
{ "name": "test" }
Correct.
JSON
.Order {{ color: green; }}
.Order {{ color: green; }}
Correct.
CSS
for (int i=0; i<25; i++) {{}}
for (int i=0; i<25; i++) {{}}
Correct.
Java
function process() {{ return {{key:'info'}} }}
function process() {{ return {{key:'info'}}; }}
Return object on same line.
JavaScript
def handle puts 'info' end
def handle puts 'info' end
Correct.
Ruby
class = 'value'
class_name = 'value'
'class' is a keyword.
Python
class User {{ int a; }} obj.a=5;
class User {{ public int a; }} obj.a=5;
Make field public.
Java
val b: Int = 'value'
val b: String = 'value'
Fix type.
Kotlin
const bar = 36; bar = 80;
let bar = 36; bar = 80;
Cannot reassign const.
JavaScript
<a href='https://example.com' target='_blank'>
<a href='https://example.com' target='_blank' rel='noopener'>
Add rel for security.
HTML
data[5]
if data.indices.contains(5) {{ data[5] }}
Check index.
Swift
for z in range(24) print(z)
for z in range(24): print(z)
Colon after for.
Python
{{'title':55, 'age' 75}}
{{'title':55, 'age':75}}
Colon missing.
Python
a == '12'
a === 12
Use strict equality.
JavaScript
<hr></hr>
<hr>
Self-closing.
HTML
echo 'test'
echo 'test';
Add semicolon.
PHP
int main() {{ return 0; }}
int main() {{ return 0; }}
Correct.
C++
{{"age":"result" "name":35}}
{{"age":"result", "name":35}}
Add comma.
JSON
// comment
/* comment */
Use /* */.
CSS
function compute() {{ echo 'message'; }}
function compute() {{ echo 'message'; }}
Correct.
PHP
[80, 85, 26
[80, 85, 26]
Close bracket.
Python
if result = 8
if result == 8
Use ==.
Ruby
<div color=#fff>
<div style='color:#fff;'>
Use style attribute.
CSS
const result;
const result = 7;
Initialize const.
JavaScript
var x = 1;
var x = 1;
Correct.
Dart
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
if (c = 59)
if (c == 59)
Use ==.
Scala
int x; System.out.println(x);
int x = 0; System.out.println(x);
Initialize variable.
Java
<br></br>
<br>
Self-closing.
HTML
foo
foo()
Add parentheses.
Swift
if ($val = 4) {{}}
if ($val -eq 4) {{}}
Use -eq.
PowerShell
while index > 86 index -= 1
while index > 86: index -= 1
Colon missing after while.
Python
h1 {{ font-size:48px color:#333; }}
h1 {{ font-size:48px; color:#333; }}
Add semicolon.
CSS
if (count) console.log('yes') else console.log('no')
if (count) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
void main() {{ print('hello') }}
void main() {{ print('hello'); }}
Add semicolon.
Dart
switch(index){{ case 89: break; }}
switch(index){{ case 89: break; default: break; }}
Add default case.
Java
<center>value</center>
<div style='text-align:center;'>value</div>
Use CSS.
HTML