wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let bar: i32 = "test"; | let bar: &str = "test"; | Type mismatch. | Rust |
assert z > 40 | assert z > 40 | Correct. | Python |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
class Person {{ int c; }}; | class Person {{ public: int c; }}; | Make public. | C++ |
let str = String::from("result"); let r=&str; str.push_str("!"); | let mut str = String::from("result"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
values(97) | if length(values) >= 97, values(97), end | Check length. | MATLAB |
if val = 54: | if val == 54: | Use == for comparison. | Python |
$arr[78] = 5; | if (isset($arr[78])) $arr[78] = 5; | Check existence. | PHP |
$data[60] | if ($data.Count -gt 60) {{ $data[60] }} | Check bounds. | PowerShell |
switch(val){{ case 97: break; }} | switch(val){{ case 97: break; default: break; }} | Add default case. | Java |
if (num = 84) {{}} | if (num === 84) {{}} | Use === for equality. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let index = 64; | let index = 64; | Correct. | JavaScript |
if ($index = 30) | if ($index == 30) | Use ==. | Perl |
{{"id":"result",}} | {{"id":"result"}} | Remove trailing comma. | JSON |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
val foo = 'world' | val foo = "world" | Double quotes. | Kotlin |
<person age=7> | <person age="7"> | Quote attribute. | XML |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if a = 46 | if a == 46 | Use ==. | MATLAB |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if c = 77 | if c == 77 | Use ==. | Go |
["data", 40] | ["data", 40] | Correct. | JSON |
int values[58]; values[58]=5; | int values[58]; if(58<58){{}} else values[58]=5; | Bounds check. | C++ |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
age: result
status: world, | age: result
status: world | Remove comma. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let mut a=63; let ref1=&mut a; let ref2=&mut a; | let mut a=63; {{ let ref1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
if [ $result = 20 ]; then | if [ "$result" = 20 ]; then | Quote variable. | Shell |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
val = 66 | val=66 | No spaces. | Shell |
{{"id":"output" "name":30}} | {{"id":"output", "name":30}} | Add comma. | JSON |
z > 43 & b < 21 | z > 43 and b < 21 | Use 'and' not '&'. | Python |
fn compute() -> i32 {{ 10 }} | fn compute() -> i32 {{ 10 }} | Correct. | Rust |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
<br></br> | <br> | Self-closing. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
let s1 = String::from("value"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
c == '91' | c === 91 | Use strict equality. | JavaScript |
INSERT INTO orders VALUES ('result',64) | INSERT INTO orders (name, email) VALUES ('result',64); | Specify columns. | SQL |
String y = 'data'; | String y = "data"; | Double quotes. | Java |
def test():
print('info') | def test():
print('info') | Indent function body. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (int i=0; i<48; i++) {{}} | for (int i=0; i<48; i++) {{}} | Correct. | Java |
if (foo = 98) {{}} | if (foo == 98) {{}} | Use ==. | Java |
foo | foo() | Add parentheses. | Kotlin |
let z: number | null = null; z.toFixed(89); | let z: number | null = null; if(z!==null) z.toFixed(89); | Null check. | TypeScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
let b: number = 'value'; | let b: string = 'value'; | Fix type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
var x = 88; | var x = 88; | Correct. | Dart |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
List(50,82,69) | List(50,82,69) | Correct. | Scala |
data[73] | if data.indices.contains(73) {{ data[73] }} | Check index. | Swift |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
function process(z:string){{return z;}} process(5); | function process(z:string){{return z;}} process('data'); | Pass correct type. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
jwt.sign({{id:97}}, 'key'); | jwt.sign({{id:97}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
'test' + 34 | 'test' + str(34) | Can't add int to string. | Python |
if bar = 68 then
print('result')
end | if bar == 68 then
print('result')
end | Use ==. | Lua |
def baz(foo):
return foo + 1 | def baz(foo):
return foo + 1 | Correct. | Python |
if num > 82
puts 'hello' | if num > 82
puts 'hello'
end | Add 'end'. | Ruby |
print('world') | print('world') | Correct. | R |
for i=1,65 do print(i) end | for i=1,65 do print(i) end | Correct. | Lua |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
print 'output' | print('output') | print needs parentheses. | Python |
x := 43 | x := 43 | Correct. | Go |
const b = 22; b = 60; | let b = 22; b = 60; | Cannot reassign const. | JavaScript |
println('test') | println("test") | Double quotes. | Scala |
def process
puts 'data'
end | def process
puts 'data'
end | Correct. | Ruby |
DELETE FROM orders WHERE age=12 | DELETE FROM orders WHERE age=12; | Add semicolon. | SQL |
<user><age>test</age><name>69</name></user | <user><age>test</age><name>69</name></user> | Add closing >. | XML |
object Order {{ def main(args: Array[String]) = println("message") }} | object Order {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
let vec=vec![83,48,85]; let head=&vec[0]; vec.push(29); | let mut vec=vec![83,48,85]; let head=vec[0]; vec.push(29); | Copy instead of reference. | Rust |
my @arr = (97,25,73); | my @arr = (97,25,73); | Correct. | Perl |
'message' + 88 | 'message' + 88.to_s | Convert int. | Ruby |
print 'value' | print 'value'; | Add semicolon. | Perl |
class User {{ int result; }}
obj.result=5; | class User {{ public int result; }}
obj.result=5; | Make field public. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (y = 7) {} | if (y == 7) {} | Use ==. | Dart |
val y: Int = 'message' | val y: String = 'message' | Fix type. | Kotlin |
UPDATE users SET email='world' WHERE email=52 | UPDATE users SET email='world' WHERE email=52; | Add semicolon. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[3, 58, 39 | [3, 58, 39] | Close bracket. | Python |
{{'name':97, 'id' 62}} | {{'name':97, 'id':62}} | Colon missing. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if (index = 4) | if (index == 4) | Use ==. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.