richardhundt / shine

A Shiny Lua Dialect
Other
231 stars 18 forks source link

hi, bug too #75

Closed miketang84 closed 9 years ago

miketang84 commented 9 years ago

import async from "async"

f1 = async => x = 0 for i=1, 42 do -- some computation x += 1 end return x end print f1.join() -- schedule until done (prints 42)

mike@mike-T410s:~/workspace/learn_shine$ shine async.shn Error: ./async.shn:3: attempt to call local 'async' (a table value) stack traceback: ./async.shn:3: in main chunk [C]: in function 'require' [string "core"]: in function 'import' async.shn:1: in main chunk [string "shine"]: in main chunk [string "shine"]: in main chunk [C]: at 0x00454c60

richardhundt commented 9 years ago

I can't reproduce it, this is what I see:

windhoek:shine richard$ cat async.shn 
import async from "async"

f1 = async =>
   x = 0
   for i=1, 42 do
      -- some computation
      x += 1
   end
   return x
end
print f1.join() -- schedule until done (prints 42)
windhoek:shine richard$ shine async.shn 
42
richardhundt commented 9 years ago

okay, I've managed to reproduce it - there's a conflict with having the file named async and then doing import ... from 'async' - you end up loading the current module because files in the current directory take precedence over installed modules. Try renaming your test.

richardhundt commented 9 years ago

incidentally, this doesn't work with Lua either, however you'd get

luajit: ./foo.lua:1: loop or previous error loading module 'foo'

so I guess Shine should also raise an error in this case

miketang84 commented 9 years ago

:D , it make sense.