"andalso" bad argument
"andalso" is just not working for me in erlide. It does not work in my module, but it does work at the erlang shell. I am stumped. The module in question is:
-module(mytest).
-export([mytest/0]).
mytest() ->
true andalso blue.
...and when I start a debug and run the above function...
Eshell V5.8.2
(default@phobos)1> mytest:mytest().
called as mytest:mytest()
(default@phobos)2> true andalso green.
green
Everything works as expected when I use a non-erlide erlang instance.
PS C:\Users\goertzen\workspace\mytest\src> C:\erlang\bin\erl.exe
Eshell V5.8.2 (abort with ^G)
1> c(mytest).
{ok,mytest}
2> mytest:mytest().
blue
3> true andalso green.
green
-module(mytest).
-export([mytest/0]).
mytest() ->
true andalso blue.
...and when I start a debug and run the above function...
Eshell V5.8.2
(default@phobos)1> mytest:mytest().
- exception error: bad argument: blue
called as mytest:mytest()
(default@phobos)2> true andalso green.
green
Everything works as expected when I use a non-erlide erlang instance.
PS C:\Users\goertzen\workspace\mytest\src> C:\erlang\bin\erl.exe
Eshell V5.8.2 (abort with ^G)
1> c(mytest).
{ok,mytest}
2> mytest:mytest().
blue
3> true andalso green.
green
Leave a comment
on 2011-03-14 19:15 *
By Vlad Dumitrescu
It works for me - Could it be that your project gets compiled with R12? I get this error when I do that, but works fine with R13+.
Please check the project properties, the "Erlang" tab.
Please check the project properties, the "Erlang" tab.
on 2011-03-14 19:45 *
By Vlad Dumitrescu
I hope I guessed right who the submitter is :-) Repeating the message in case Assembla doesn't send old comments:
It works for me - Could it be that your project gets compiled with R12? I get this error when I do that, but works fine with R13+.
Please check the project properties, the "Erlang" tab.
It works for me - Could it be that your project gets compiled with R12? I get this error when I do that, but works fine with R13+.
Please check the project properties, the "Erlang" tab.
on 2011-03-14 19:48 *
By daniel.goertzen
Thanks, I thought I was logged in when I submitted the ticket, but I guess I wasn't. I am looking into your suggestions.
Dan.
Dan.
on 2011-03-14 19:48 *
By daniel.goertzen
Thanks, I thought I was logged in when I submitted the ticket, but I guess I wasn't. I am looking into your suggestions.
Dan.
Dan.
on 2011-03-14 20:07 *
By daniel.goertzen
You are on to something. If I manually compile the thing, it works.
(default@phobos)7> c("mytest/src/mytest").
{ok,mytest}
(default@phobos)8> mytest:mytest().
blue
I've inspected all the running erl.exe processes with process explorer, and they are definitely using the beam dll from R14B01. Does erlide use a temporary emulator for compiling?
I am 99% sure I don't have R12 in my system.
(default@phobos)7> c("mytest/src/mytest").
{ok,mytest}
(default@phobos)8> mytest:mytest().
blue
I've inspected all the running erl.exe processes with process explorer, and they are definitely using the beam dll from R14B01. Does erlide use a temporary emulator for compiling?
I am 99% sure I don't have R12 in my system.
on 2011-03-14 20:28 *
By Vlad Dumitrescu
Please check window->preferences->erlang->installed runtimes, just to be sure.
We don't install any erlang runtime, so if you only have R14, then it's the only one that can be used.... weird!
Could you attach the "bad" mytest.beam?
We don't install any erlang runtime, so if you only have R14, then it's the only one that can be used.... weird!
Could you attach the "bad" mytest.beam?
on 2011-03-14 20:32 *
By daniel.goertzen
If I manually purge and reload the module, it works correctly. I note that the module_info() report is different depending on whether erlide loaded it or if I manually loaded it. Is the compile attribute supposed to be empty?
(default@phobos)4> mytest:mytest().
called as mytest:mytest()
(default@phobos)5> mytest:module_info().
[{compile,[]},
{attributes,[{file,{"c:/Users/goertzen/workspace/mytest/src/mytest.erl",
1}}]},
{imports,[]},
{exports,[{module_info,0},
{module_info,1},
{mytest,0},
{ver,0}]}]
(default@phobos)6> code:soft_purge(mytest).
true
(default@phobos)7> code:load_file(mytest).
{module,mytest}
(default@phobos)8> mytest:mytest().
blue
(default@phobos)9> mytest:module_info().
[{exports,[{mytest,0},
{ver,0},
{module_info,0},
{module_info,1}]},
{imports,[]},
{attributes,[{vsn,[34679975159743558356958668695363172021]}]},
{compile,[{options,[return_errors,return_warnings,
{i,"C:/Users/goertzen/workspace/mytest/include"},
debug_info,
{warn_format,1},
debug_info]},
{version,"4.7.2"},
{time,{2011,3,14,14,52,53}},
{source,"c:/Users/goertzen/workspace/mytest/src/mytest.erl"}]}]
(default@phobos)10>
Note that I added the export ver/0 to mytest to print some system information.
(default@phobos)4> mytest:mytest().
- exception error: bad argument: blue
called as mytest:mytest()
(default@phobos)5> mytest:module_info().
[{compile,[]},
{attributes,[{file,{"c:/Users/goertzen/workspace/mytest/src/mytest.erl",
1}}]},
{imports,[]},
{exports,[{module_info,0},
{module_info,1},
{mytest,0},
{ver,0}]}]
(default@phobos)6> code:soft_purge(mytest).
true
(default@phobos)7> code:load_file(mytest).
{module,mytest}
(default@phobos)8> mytest:mytest().
blue
(default@phobos)9> mytest:module_info().
[{exports,[{mytest,0},
{ver,0},
{module_info,0},
{module_info,1}]},
{imports,[]},
{attributes,[{vsn,[34679975159743558356958668695363172021]}]},
{compile,[{options,[return_errors,return_warnings,
{i,"C:/Users/goertzen/workspace/mytest/include"},
debug_info,
{warn_format,1},
debug_info]},
{version,"4.7.2"},
{time,{2011,3,14,14,52,53}},
{source,"c:/Users/goertzen/workspace/mytest/src/mytest.erl"}]}]
(default@phobos)10>
Note that I added the export ver/0 to mytest to print some system information.
file:dLYRswtKWr4i_neJe5cbLr: the "bad" beam
on 2011-03-14 20:40 *
By daniel.goertzen
BTW, I double checked my system and I have no old installations. I removed R14A so now I only have R14B.
I also verified window->preferences->erlang->installed runtimes and it is correctly using my R14B installation.
I also verified window->preferences->erlang->installed runtimes and it is correctly using my R14B installation.
on 2011-03-15 01:19 *
By Vlad Dumitrescu
When I load this bad beam, I get good info and it also works fine:
12> mytest:module_info().
[{exports,[{mytest,0},
{ver,0},
{module_info,0},
{module_info,1}]},
{imports,[]},
{attributes,[{vsn,[34679975159743558356958668695363172021]}]},
{compile,[{options,[return_errors,return_warnings,
{i,"C:/Users/goertzen/workspace/mytest/include"},
debug_info,
{warn_format,1},
debug_info]},
{version,"4.7.2"},
{time,{2011,3,14,15,6,6}},
{source,"c:/Users/goertzen/workspace/mytest/src/mytest.erl"}]}]
So it's compiled all right...
The bad module_info that you see is weird: the elements in all lists are in reversed order (module_info is always last in the exports list) and there is a -file attribute...
What's your code:get_path()?
What is code:which(mytest) when the bad one is loaded?
12> mytest:module_info().
[{exports,[{mytest,0},
{ver,0},
{module_info,0},
{module_info,1}]},
{imports,[]},
{attributes,[{vsn,[34679975159743558356958668695363172021]}]},
{compile,[{options,[return_errors,return_warnings,
{i,"C:/Users/goertzen/workspace/mytest/include"},
debug_info,
{warn_format,1},
debug_info]},
{version,"4.7.2"},
{time,{2011,3,14,15,6,6}},
{source,"c:/Users/goertzen/workspace/mytest/src/mytest.erl"}]}]
So it's compiled all right...
The bad module_info that you see is weird: the elements in all lists are in reversed order (module_info is always last in the exports list) and there is a -file attribute...
What's your code:get_path()?
What is code:which(mytest) when the bad one is loaded?
on 2011-03-15 01:31 *
By daniel.goertzen
Here are get_path() and which() results. I also repeated which() for when the module is manually loaded.
(default@phobos)6> mytest:mytest().
called as mytest:mytest()
(default@phobos)7> io:format("~p~n",[code:get_path()]).
["c:/Users/goertzen/workspace/mytest/ebin",
"c:/eclipse/plugins/org.erlide.kernel.ide_0.10.1.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.tracing.erlang_0.2.3.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.tracing.ttbe_0.1.2.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.kernel.builder_0.10.1.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.kernel.debugger_0.10.1.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.wrangler.core_0.9.4.201103021517/wrangler/app",
"c:/eclipse/plugins/org.erlide.wrangler.core_0.9.4.201103021517/wrangler/ebin",
"c:/eclipse/configuration/org.eclipse.osgi/bundles/305/1/.cp/ebin",
"c:/eclipse/plugins/org.erlide.kernel.common_0.10.1.201103021517/ebin",".",
"c:/erlang/lib/kernel-2.14.2/ebin","c:/erlang/lib/stdlib-1.17.2/ebin",
"c:/erlang/lib/xmerl-1.2.7/ebin","c:/erlang/lib/wx-0.98.8/ebin",
"c:/erlang/lib/webtool-0.8.7/ebin","c:/erlang/lib/typer-0.1.7.5/ebin",
"c:/erlang/lib/tv-2.1.4.6/ebin","c:/erlang/lib/tools-2.6.6.2/ebin",
"c:/erlang/lib/toolbar-1.4.1/ebin","c:/erlang/lib/test_server-3.4.2/ebin",
"c:/erlang/lib/syntax_tools-1.6.7/ebin","c:/erlang/lib/ssl-4.1.1/ebin",
"c:/erlang/lib/ssh-2.0.3/ebin","c:/erlang/lib/snmp-4.18/ebin",
"c:/erlang/lib/sasl-2.1.9.2/ebin","c:/erlang/lib/runtime_tools-1.8.4.1/ebin",
"c:/erlang/lib/reltool-0.5.4/ebin","c:/erlang/lib/public_key-0.10/ebin",
"c:/erlang/lib/pman-2.7.1/ebin","c:/erlang/lib/percept-0.8.4/ebin",
"c:/erlang/lib/parsetools-2.0.5/ebin","c:/erlang/lib/otp_mibs-1.0.6/ebin",
"c:/erlang/lib/os_mon-2.2.5/ebin","c:/erlang/lib/orber-3.6.18/ebin",
"c:/erlang/lib/odbc-2.10.9/ebin","c:/erlang/lib/observer-0.9.8.4/ebin",
"c:/erlang/lib/mnesia-4.4.16/ebin","c:/erlang/lib/megaco-3.15/ebin",
"c:/erlang/lib/jinterface-1.5.3.2","c:/erlang/lib/inviso-0.6.2/ebin",
"c:/erlang/lib/inets-5.5.1/ebin","c:/erlang/lib/ic-4.2.25/ebin",
"c:/erlang/lib/hipe-3.7.8/ebin","c:/erlang/lib/gs-1.5.13/ebin",
"c:/erlang/lib/eunit-2.1.6/ebin","c:/erlang/lib/et-1.4.2/ebin",
"c:/erlang/lib/erts-5.8.2/ebin","c:/erlang/lib/erl_interface-3.7.2",
"c:/erlang/lib/erl_docgen-0.2.3/ebin","c:/erlang/lib/edoc-0.7.6.8/ebin",
"c:/erlang/lib/docbuilder-0.9.8.9/ebin","c:/erlang/lib/dialyzer-2.4.0/ebin",
"c:/erlang/lib/debugger-3.2.5/ebin","c:/erlang/lib/crypto-2.0.2/ebin",
"c:/erlang/lib/cosTransactions-1.2.10/ebin",
"c:/erlang/lib/cosTime-1.1.9/ebin","c:/erlang/lib/cosProperty-1.1.12/ebin",
"c:/erlang/lib/cosNotification-1.1.15/ebin",
"c:/erlang/lib/cosFileTransfer-1.1.10/ebin",
"c:/erlang/lib/cosEventDomain-1.1.9/ebin",
"c:/erlang/lib/cosEvent-2.1.9/ebin","c:/erlang/lib/compiler-4.7.2/ebin",
"c:/erlang/lib/common_test-1.5.2/ebin","c:/erlang/lib/asn1-1.6.15/ebin",
"c:/erlang/lib/appmon-2.1.13/ebin"]
ok
(default@phobos)8> code:which(mytest).
"c:/Users/goertzen/workspace/mytest/ebin/mytest.beam"
(default@phobos)9> code:purge(mytest).
false
(default@phobos)10> code:load_file(mytest).
{module,mytest}
(default@phobos)11> mytest:mytest().
blue
(default@phobos)12> code:which(mytest).
"c:/Users/goertzen/workspace/mytest/ebin/mytest.beam"
(default@phobos)6> mytest:mytest().
- exception error: bad argument: blue
called as mytest:mytest()
(default@phobos)7> io:format("~p~n",[code:get_path()]).
["c:/Users/goertzen/workspace/mytest/ebin",
"c:/eclipse/plugins/org.erlide.kernel.ide_0.10.1.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.tracing.erlang_0.2.3.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.tracing.ttbe_0.1.2.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.kernel.builder_0.10.1.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.kernel.debugger_0.10.1.201103021517/ebin",
"c:/eclipse/plugins/org.erlide.wrangler.core_0.9.4.201103021517/wrangler/app",
"c:/eclipse/plugins/org.erlide.wrangler.core_0.9.4.201103021517/wrangler/ebin",
"c:/eclipse/configuration/org.eclipse.osgi/bundles/305/1/.cp/ebin",
"c:/eclipse/plugins/org.erlide.kernel.common_0.10.1.201103021517/ebin",".",
"c:/erlang/lib/kernel-2.14.2/ebin","c:/erlang/lib/stdlib-1.17.2/ebin",
"c:/erlang/lib/xmerl-1.2.7/ebin","c:/erlang/lib/wx-0.98.8/ebin",
"c:/erlang/lib/webtool-0.8.7/ebin","c:/erlang/lib/typer-0.1.7.5/ebin",
"c:/erlang/lib/tv-2.1.4.6/ebin","c:/erlang/lib/tools-2.6.6.2/ebin",
"c:/erlang/lib/toolbar-1.4.1/ebin","c:/erlang/lib/test_server-3.4.2/ebin",
"c:/erlang/lib/syntax_tools-1.6.7/ebin","c:/erlang/lib/ssl-4.1.1/ebin",
"c:/erlang/lib/ssh-2.0.3/ebin","c:/erlang/lib/snmp-4.18/ebin",
"c:/erlang/lib/sasl-2.1.9.2/ebin","c:/erlang/lib/runtime_tools-1.8.4.1/ebin",
"c:/erlang/lib/reltool-0.5.4/ebin","c:/erlang/lib/public_key-0.10/ebin",
"c:/erlang/lib/pman-2.7.1/ebin","c:/erlang/lib/percept-0.8.4/ebin",
"c:/erlang/lib/parsetools-2.0.5/ebin","c:/erlang/lib/otp_mibs-1.0.6/ebin",
"c:/erlang/lib/os_mon-2.2.5/ebin","c:/erlang/lib/orber-3.6.18/ebin",
"c:/erlang/lib/odbc-2.10.9/ebin","c:/erlang/lib/observer-0.9.8.4/ebin",
"c:/erlang/lib/mnesia-4.4.16/ebin","c:/erlang/lib/megaco-3.15/ebin",
"c:/erlang/lib/jinterface-1.5.3.2","c:/erlang/lib/inviso-0.6.2/ebin",
"c:/erlang/lib/inets-5.5.1/ebin","c:/erlang/lib/ic-4.2.25/ebin",
"c:/erlang/lib/hipe-3.7.8/ebin","c:/erlang/lib/gs-1.5.13/ebin",
"c:/erlang/lib/eunit-2.1.6/ebin","c:/erlang/lib/et-1.4.2/ebin",
"c:/erlang/lib/erts-5.8.2/ebin","c:/erlang/lib/erl_interface-3.7.2",
"c:/erlang/lib/erl_docgen-0.2.3/ebin","c:/erlang/lib/edoc-0.7.6.8/ebin",
"c:/erlang/lib/docbuilder-0.9.8.9/ebin","c:/erlang/lib/dialyzer-2.4.0/ebin",
"c:/erlang/lib/debugger-3.2.5/ebin","c:/erlang/lib/crypto-2.0.2/ebin",
"c:/erlang/lib/cosTransactions-1.2.10/ebin",
"c:/erlang/lib/cosTime-1.1.9/ebin","c:/erlang/lib/cosProperty-1.1.12/ebin",
"c:/erlang/lib/cosNotification-1.1.15/ebin",
"c:/erlang/lib/cosFileTransfer-1.1.10/ebin",
"c:/erlang/lib/cosEventDomain-1.1.9/ebin",
"c:/erlang/lib/cosEvent-2.1.9/ebin","c:/erlang/lib/compiler-4.7.2/ebin",
"c:/erlang/lib/common_test-1.5.2/ebin","c:/erlang/lib/asn1-1.6.15/ebin",
"c:/erlang/lib/appmon-2.1.13/ebin"]
ok
(default@phobos)8> code:which(mytest).
"c:/Users/goertzen/workspace/mytest/ebin/mytest.beam"
(default@phobos)9> code:purge(mytest).
false
(default@phobos)10> code:load_file(mytest).
{module,mytest}
(default@phobos)11> mytest:mytest().
blue
(default@phobos)12> code:which(mytest).
"c:/Users/goertzen/workspace/mytest/ebin/mytest.beam"
on 2011-03-15 01:50 *
By Vlad Dumitrescu
Extremely weird... At least we know it's not the compilation, because loading manually makes it work.
If you copy the module giving it another name and save it, then check module_info in the console, does it look right or weird?
I forgot to ask which version you are running - the log wasn't complete.
If you copy the module giving it another name and save it, then check module_info in the console, does it look right or weird?
I forgot to ask which version you are running - the log wasn't complete.
on 2011-03-15 02:38 *
By daniel.goertzen
I couldn't use a renamed copy of the same module; I suspect it barfed because the internal name didn't match the filename. Instead I copied a beam from a different project into the ebin/ directory. module_info() on that produced good results.
I took a look at the larger application I am working with. It runs fine in erlide, but all of my modules have bad module_info(). As long as I don't use "andalso", I am okay (I just discovered andalso the other day, so it hasn't bothered me until now. :)
I wonder if the VM executes a module differently based on the version appearing in module_info(). Since my modules are missing version info, perhaps the VM is assuming R12 andalso behavior.
version info: Erlang IDE 0.10.2.201103021517
I took a look at the larger application I am working with. It runs fine in erlide, but all of my modules have bad module_info(). As long as I don't use "andalso", I am okay (I just discovered andalso the other day, so it hasn't bothered me until now. :)
I wonder if the VM executes a module differently based on the version appearing in module_info(). Since my modules are missing version info, perhaps the VM is assuming R12 andalso behavior.
version info: Erlang IDE 0.10.2.201103021517
on 2011-03-15 03:02 *
By Vlad Dumitrescu
So it is only one project that produces bad beams?
Please try one more thing: delete all beam files in the project, rebuild it and open a command line in the ebin directory. Start erl manually there and check mytest:module_info().
Your explanation about the missing version info might be right, but the interesting problem is why and how are those bad beams generated?
Please try one more thing: delete all beam files in the project, rebuild it and open a command line in the ebin directory. Start erl manually there and check mytest:module_info().
Your explanation about the missing version info might be right, but the interesting problem is why and how are those bad beams generated?
on 2011-03-15 07:02 *
By daniel.goertzen
It happened in my "big" project first, then I created a second project to test this problem and it immediately happened there too.
In the initial bug report I showed that the beams that failed in erlide worked fine in a command line erlang. Also, the same beam worked fine for you, so I think the problem is not with the beams.
I just uncovered another clue while thinking about this...
If I go into debug configurations -> Debug -> Interpreted modules, uncheck everything, and restart the debug config, then mytest:module_info() and mytest:mytest() produce correct results. Just to make sure, I went back in and checked all the interpreted modules, and sure enough mytest behaved badly again. Could erlide be mis-loading modules?
In the initial bug report I showed that the beams that failed in erlide worked fine in a command line erlang. Also, the same beam worked fine for you, so I think the problem is not with the beams.
I just uncovered another clue while thinking about this...
If I go into debug configurations -> Debug -> Interpreted modules, uncheck everything, and restart the debug config, then mytest:module_info() and mytest:mytest() produce correct results. Just to make sure, I went back in and checked all the interpreted modules, and sure enough mytest behaved badly again. Could erlide be mis-loading modules?
on 2011-03-15 14:02 *
By Vlad Dumitrescu
Okay, I had missed you had said that you were debugging and I never had ran module_info on an interpreted module...
The problem is that we have our own debugger code which is probably based on R12. Since then there have been updates for handling andalso, orelse and comprehensions.
We will have to update the debugger. I opened https://www.assembla.com/spaces/erlide/tickets/802-debugger--update-to-r14 with only the necessary information (this one has grown too much and it's not going to be me that does the fix to the debugger) and will close this one as duplicate.
Thanks for the report and for the help to finding the problem!
The problem is that we have our own debugger code which is probably based on R12. Since then there have been updates for handling andalso, orelse and comprehensions.
We will have to update the debugger. I opened https://www.assembla.com/spaces/erlide/tickets/802-debugger--update-to-r14 with only the necessary information (this one has grown too much and it's not going to be me that does the fix to the debugger) and will close this one as duplicate.
Thanks for the report and for the help to finding the problem!
on 2011-03-15 14:03 *
By Vlad Dumitrescu
Status changed from New to Duplicate
Status changed from New to Duplicate