Problem with bit syntax compilation

Jouni.Ryno@REDACTED Jouni.Ryno@REDACTED
Mon Apr 16 21:30:43 CEST 2001


> "Jouni Ryno" <jouni.ryno@REDACTED> writes:
> 
> > error(Test) ->
> >     if
> > 	Test == 1 ->
> > 	    Problem = 1;
> > 	Test == 2 ->
> > 	    Problem = 2
> >     end,
> >     Dummy = 1,
> >     OKbin = <<Test:7, Dummy:9>>,    % used only to prove, that it works 
> > normally
> >     MyBin = [<<Test:7, Problem:9>>, OKbin].
> > 
> > I get compilation error from erlc test.erl (eshell V5.0.2
> 
> Although it does look like a bug, you missed the warning:
> 
>   /tmp/test.erl:12: Warning: variable 'Problem' exported from 'if' (line 4)
> 
I do NOT get the warning ! Hmm, do you get the warning, if you add the 
fallback
true ->
	Problem = 3 % default 

??

But the following does make it work, even in my real life case !
Thanks !

> So instead try:
> 
>    ,----
>    | error(Test) ->
>    |     Problem = if
>    |                   Test == 1 ->
>    |                       1;
>    |                   Test == 2 ->
>    |                       2
>    |               end,
>    |     Dummy = 1,
>    |     OKbin = <<Test:7, Dummy:9>>,
>    |     MyBin = [<<Test:7, Problem:9>>, OKbin].
>    `----
> 
> 
> Regards,
>    --Daniel
> 
> -- 
> Daniel Neri
> dne@REDACTED



  Jouni Rynö                            mailto://Jouni.Ryno@fmi.fi/
                                        http://www.geo.fmi.fi/~ryno/
  Finnish Meteorological Institute      http://www.fmi.fi/
  Geophysical Research                  http://www.geo.fmi.fi/
  P.O.BOX 503                           Tel      (+358)-9-19294656
  FIN-00101 Helsinki                    FAX      (+358)-9-19294603
  Finland                               priv-GSM (+358)-50-5302903
  
  "It's just zeros and ones, it cannot be hard"







More information about the erlang-questions mailing list