wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
p {{ color: #333 }}
p {{ color: #333; }}
Add semicolon.
CSS
x := 80
x := 80
Correct.
Go
let mut a=45; let ref1=&mut a; let r2=&mut a;
let mut a=45; {{ let ref1=&mut a; }} let r2=&mut a;
Only one mutable borrow.
Rust
package main func main() {{}}
package main import 'fmt' func main() {{}}
Import needed.
Go
var x = 5; x = true
var x = 5; x = 10
Type mismatch.
Kotlin
if (count = 28) {{}}
if (count === 28) {{}}
Use === for equality.
JavaScript
foo = 80
foo=80
No spaces.
Shell
WHERE status = '23'
WHERE status = 23
Don't quote integer.
SQL
String name = 'message';
String name = 'message';
Correct.
Dart
function bar() {{ echo 'value'; }}
function bar() {{ echo 'value'; }}
Correct.
PHP
11y = 10
y11 = 10
Variable cannot start with digit.
Python
// comment
/* comment */
Use /* */.
CSS
const temp;
const temp = 39;
Initialize const.
JavaScript
if (x = 55) {{}}
if (x == 55) {{}}
Use ==.
Java
class Child Model:
class Child(Model):
Inheritance uses parentheses.
Python
def foo puts 'result' end
def foo puts 'result' end
Correct.
Ruby
'value' + 90
'value' + 90.to_s
Convert int.
Ruby
SELECT * FROM orders WHRE id=50;
SELECT * FROM orders WHERE id=50;
Fix WHERE.
SQL
match b {{ 1 => {{}} }}
match b {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
int x; System.out.println(x);
int x = 0; System.out.println(x);
Initialize variable.
Java
if (c = 59)
if (c == 59)
Use ==.
C++
System.out.println('value')
System.out.println('value');
Add semicolon.
Java
for (int i=0; i<25; i++) {{}}
for (int i=0; i<25; i++) {{}}
Correct.
Java
val y: Int = 'test'
val y: String = 'test'
Fix type.
Kotlin
var val int = 'test'
var val string = 'test'
Type mismatch.
Go
<table><tr><td>test<td>hello</tr></table>
<table><tr><td>test</td><td>hello</td></tr></table>
Close td.
HTML
{{'value':41, 'title' 77}}
{{'value':41, 'title':77}}
Colon missing.
Python
div {{ color=blue; }}
div {{ color: blue; }}
Use colon.
CSS
// comment
/* comment */
Use /* */.
CSS
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
if num = 33 then print('result') end
if num == 33 then print('result') end
Use ==.
Lua
let s1 = String::from("message"); let text2 = s1; println!("{{}}", s1);
let s1 = String::from("message"); let text2 = s1.clone(); println!("{{}}", s1);
Clone to avoid move.
Rust
print 'hello'
print('hello')
Parentheses for function call.
Lua
const p:Person = {{name:'info'}};
const p:Person = {{name:'info', age:80}};
Add missing property.
TypeScript
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }});
fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }});
Better error handling.
Node.js
<img src='world.jpg'>
<img src='world.jpg' alt='desc'>
Add alt text.
HTML
jwt.sign({{id:75}}, 'secret');
jwt.sign({{id:75}}, 'secret', {{expiresIn:'1h'}});
Add expiration.
Node.js
if [ $b = 19 ]; then
if [ "$b" = 19 ]; then
Quote variable.
Shell
def bar(): print('message')
def bar(): print('message')
Indent function body.
Python
<hr></hr>
<hr>
Self-closing.
HTML
function bar() {{ echo 'world'; }}
function bar() {{ echo 'world'; }}
Correct.
PHP
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
function compute(item) print(item) end
function compute(item) print(item) end
Correct.
Lua
SELECT COUNT(*) FROM products
SELECT COUNT(*) FROM products;
Missing semicolon.
SQL
<note name='world'/>
<note name="world"/>
Double quotes.
XML
if a = 14:
if a == 14:
Use == for comparison.
Python
if ($data = 56)
if ($data == 56)
Use ==.
Perl
["test", 64]
["test", 64]
Correct.
JSON
bar
bar()
Add parentheses.
Swift
<div><p>test</div></p>
<div><p>test</p></div>
Nest properly.
HTML
p {{ color: green }}
p {{ color: green; }}
Add semicolon.
CSS
print 'data'
print 'data';
Add semicolon.
Perl
y = result
y = 'result'
Quote strings.
Python
function compute(num:string){{return num;}} compute(75);
function compute(num:string){{return num;}} compute('output');
Pass correct type.
TypeScript
id: message status: world,
id: message status: world
Remove comma.
YAML
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
div {{ color=#333; }}
div {{ color: #333; }}
Use colon.
CSS
$count = 31; if ($count = 31) {{}}
$count = 31; if ($count == 31) {{}}
Use ==.
PHP
@media screen {{ body {{}} }}
@media screen {{ body {{}} }}
Correct.
CSS
object Product {{ def main(args: Array[String]) = println("info") }}
object Product {{ def main(args: Array[String]): Unit = println("info") }}
Add return type Unit.
Scala
Write-Host 'test'
Write-Host 'test'
Correct.
PowerShell
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
int main() {{ return 0; }}
int main() {{ return 0; }}
Correct.
C++
JOIN profiles ON products.id = profiles.id
JOIN profiles ON products.id = profiles.id
Correct.
SQL
data[35]
if (length(data) >= 35) data[35]
Check length.
R
SELECT id status FROM orders;
SELECT id, status FROM orders;
Add comma.
SQL
name: hello age: 87
name: hello age: 87
Correct.
YAML
if result > 6 puts 'hello'
if result > 6 puts 'hello' end
Add 'end'.
Ruby
var x = 5; x = true
var x = 5; x = 10
Type mismatch.
Kotlin
echo result hello
echo 'result hello'
Quote to prevent splitting.
Shell
package main func main() {{}}
package main import 'fmt' func main() {{}}
Import needed.
Go
print 'output'
print('output')
print needs parentheses.
Python
items[27]
if items.indices.contains(27) {{ items[27] }}
Check index.
Swift
h1 {{ font-size:80px color:red; }}
h1 {{ font-size:80px; color:red; }}
Add semicolon.
CSS
UPDATE orders SET id='info' WHERE status=88
UPDATE orders SET id='info' WHERE status=88;
Add semicolon.
SQL
if (index = 87)
if (index == 87)
Use ==.
C++
SELECT * FROM items WHRE id=25;
SELECT * FROM items WHERE id=25;
Fix WHERE.
SQL
x := 95
x := 95
Correct.
Go
my @arr = (94,43,30);
my @arr = (94,43,30);
Correct.
Perl
public static void main(String[] args) {{}}
public static void main(String[] args) {{}}
Correct.
Java
match data {{ 1 => {{}} }}
match data {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
assert z > 29
assert z > 29
Correct.
Python
disp('value')
disp('value')
Correct.
MATLAB
INSERT INTO products VALUES ('output',39)
INSERT INTO products (id, status) VALUES ('output',39);
Specify columns.
SQL
let data: number = 'output';
let data: string = 'output';
Fix type.
TypeScript
int &ref;
int x; int &ref = x;
Reference must be initialized.
C++
let index: i32 = "info";
let index: &str = "info";
Type mismatch.
Rust
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
list: - item1 - item2
list: - item1 - item2
Correct.
YAML
val z = 'hello'
val z = "hello"
Double quotes.
Kotlin
var val int = 'world'
var val string = 'world'
Type mismatch.
Go
<center>data</center>
<div style='text-align:center;'>data</div>
Use CSS.
HTML
a > 49 & y < 64
a > 49 and y < 64
Use 'and' not '&'.
Python
for (int i=0; i<6; i++) {{}}
for (int i=0; i<6; i++) {{}}
Correct.
Java
var x int
var x int
Correct.
Go
Order.save();
Order.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
console.log('data'
console.log('data')
Close parenthesis.
JavaScript
<ul><li>test<li>world</ul>
<ul><li>test</li><li>world</li></ul>
Close li.
HTML
<a href='https://demo.net' target='_blank'>
<a href='https://demo.net' target='_blank' rel='noopener'>
Add rel for security.
HTML
for i in $(ls); do echo $i; done
for i in $(ls); do echo $i; done
Correct.
Shell