Can `require!` automatically rename variable if the required package name conflicts with LiveScript keyword?
For example when I using when.js, I will do something like
require! \when
when.reduce(...)
This will cause error like [Error: Parse error on line 1: Unexpected 'CASE'] because require! will put the imported package in a variable when, which is a keyword of LiveScript. The error message is not quite related with the root cause, it takes me some time before realizing when is a keyword.
So I wonder is it possible to enhance require! to make it auto detect package name conflicts with built-in keywords, and auto rename the corresponding variable (e.g., put when package to when_)?
Auto renaming might not be a good idea. I propose that an error should be thrown on trying to require! keyword with a message asking user to rename the module. require! {'when':when_} can be used to import the module as when_. The error message should be descriptive and provide the workaround clearly.
:+1:@ better error message :-1:@ auto-keyword renaming which can be easily forgotten
Thanks for comment. Now I also agree that better error message is better.