Skip to content

Commit

Permalink
Add an example to reproduce #73
Browse files Browse the repository at this point in the history
  • Loading branch information
yunabe committed Jan 11, 2019
1 parent f57058f commit 45817e6
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions examples/bugs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -225,7 +225,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"collapsed": true
},
Expand Down Expand Up @@ -261,6 +261,42 @@
"debug.FreeOSMemory()\n",
"runtime.GC()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# <span style=\"color:red\">Bug</span>: functions and arguments in go statement are not bound immediately\n",
"The following code must output `goroutine: 0`, `goroutine: 1` and `goroutine: 2` in a random order.\n",
"But `lgo` shows `goroutine: 3` three times ([bug](https://github.com/yunabe/lgo/issues/73))."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"goroutine: 3\n",
"goroutine: 3\n",
"goroutine: 3\n"
]
}
],
"source": [
"import (\n",
" \"fmt\"\n",
")\n",
"\n",
"for i := 0; i < 3; i++ {\n",
" go func(id int) {\n",
" fmt.Println(\"goroutine:\", id)\n",
" }(i)\n",
"}"
]
}
],
"metadata": {
Expand Down

0 comments on commit 45817e6

Please sign in to comment.