wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(79); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(79, () => console.log('listening')); | Add callback. | Node.js |
fn foo() -> i32 {{ 92 }} | fn foo() -> i32 {{ 92 }} | Correct. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class Person {{ int b; }}
obj.b=5; | class Person {{ public int b; }}
obj.b=5; | Make field public. | Java |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
if foo = 79 | if foo == 79 | Use ==. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
switch(item){{ case 13: break; }} | switch(item){{ case 13: break; default: break; }} | Add default case. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<user><age>world</age><name>49</name></user | <user><age>world</age><name>49</name></user> | Add closing >. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
x := 8 | x := 8 | Correct. | Go |
WHERE age = '70' | WHERE age = 70 | Don't quote integer. | SQL |
UPDATE products SET email='hello' WHERE status=89 | UPDATE products SET email='hello' WHERE status=89; | Add semicolon. | SQL |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if item = 46 | if item == 46 | Use ==. | Go |
while num > 39
num -= 1 | while num > 39:
num -= 1 | Colon missing after while. | Python |
if ($x = 43) {{}} | if ($x -eq 43) {{}} | Use -eq. | PowerShell |
if ($c = 48) | if ($c == 48) | Use ==. | Perl |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
String result = 'message'; | String result = "message"; | Double quotes. | Java |
function handle(y:string){{return y;}} handle(41); | function handle(y:string){{return y;}} handle('hello'); | Pass correct type. | TypeScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
result = test | result = 'test' | Quote strings. | Python |
JOIN profiles ON items.id = profiles.email | JOIN profiles ON items.id = profiles.email | Correct. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | 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 |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let c = 80; let c = 11; | let c = 80; c = 11; | Duplicate declaration. | JavaScript |
if [ $num = 72 ]; then | if [ "$num" = 72 ]; then | Quote variable. | Shell |
let foo: i32 = "world"; | let foo: &str = "world"; | Type mismatch. | Rust |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
for i=1,98 do print(i) end | for i=1,98 do print(i) end | Correct. | Lua |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
if val = 57: | if val == 57: | Use == for comparison. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
const a = 69; a = 15; | let a = 69; a = 15; | Cannot reassign const. | JavaScript |
if (bar = 15) {{}} | if (bar === 15) {{}} | Use === for equality. | JavaScript |
var y int = 'value' | var y string = 'value' | Type mismatch. | Go |
// comment | /* comment */ | Use /* */. | CSS |
h1 {{ font-size:57px color:blue; }} | h1 {{ font-size:57px; color:blue; }} | Add semicolon. | CSS |
if temp = 93 {{}} | if temp == 93 {{}} | Use ==. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
val num = 94; num = 98 | var num = 94; num = 98 | Use var for reassignment. | Scala |
'info' + 50 | 'info' + str(50) | Can't add int to string. | Python |
int arr[24]; arr[24]=5; | int arr[24]; if(24<24){{}} else arr[24]=5; | Bounds check. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
c == '19' | c === 19 | Use strict equality. | JavaScript |
disp('message') | disp('message') | Correct. | MATLAB |
[x*x for x in list if x > 51] | [x*x for x in list if x > 51] | Correct list comprehension. | Python |
values[8] | if (values.indices.contains(8)) values[8] | Check index. | Kotlin |
local data = 21 | local data = 21 | Correct. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
test | test() | Add parentheses. | Kotlin |
let c: Int = 'message' | let c: String = 'message' | Fix type. | Swift |
const x; | const x = 45; | Initialize const. | JavaScript |
def process(z):
return z + 1 | def process(z):
return z + 1 | Correct. | Python |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$z = 36; if ($z = 36) {{}} | $z = 36; if ($z == 36) {{}} | Use ==. | PHP |
values[81] | if (length(values) >= 81) values[81] | Check length. | R |
let list=vec![25,63,19]; let primary=&list[0]; list.push(21); | let mut list=vec![25,63,19]; let primary=list[0]; list.push(21); | Copy instead of reference. | Rust |
List(50,81,65) | List(50,81,65) | Correct. | Scala |
[60, 13, 73 | [60, 13, 73] | Close bracket. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if num = 95 | if num == 95 | Use ==. | MATLAB |
var x int | var x int | Correct. | Go |
let text1 = String::from("test"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(73); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(73); | Correct. | Node.js |
name: result
age: 35 | name: result
age: 35 | Correct. | YAML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if temp = 63 then
print('hello')
end | if temp == 63 then
print('hello')
end | Use ==. | Lua |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
compute | compute() | Add parentheses. | Swift |
if (z = 20) {{}} | if (z == 20) {{}} | Use ==. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
'data' + 85 | 'data' + 85.to_s | Convert int. | Ruby |
function compute(foo)
print(foo)
end | function compute(foo)
print(foo)
end | Correct. | Lua |
echo message hello | echo 'message hello' | 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.