• Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Social Media
    •   @Wings3dOfficial
    •   @Wings3dOfficial
    •   Wings3dOfficial
    •   Wings3dOfficial
  • Register
  • Login
  • Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Register
  • Login
Wings 3D Development Forum Wings 3D Programming v
« Previous 1 2 3 4 Next »
On wpc_hlines module, the problem of an arguments reported by dialyzer.

 
  • 0 Vote(s) - 0 Average
On wpc_hlines module, the problem of an arguments reported by dialyzer.

tkbd
Offline

Senior Member

Posts: 451
Threads: 115
Joined: Nov 2012
#1
04-08-2016, 02:26 PM
Hi!dgud,Cause was found.
(The past few week I was talking with him about the problem of wpc_hlines module on github.)

It was due to that contained complex anonymous function within the tuple on function binding( Line: around 486).
I can't understanded how an error occurs in what mechanism.

The sequence of events:
I also decided to examine the problem by using a dialyzer too.
And,Dialyzer has outputted to the same error message.

Quote: Checking whether the PLT /Users/*****/.dialyzer_plt is up-to-date... yes
Proceeding with analysis...
wpc_hlines.erl:771: The call wpc_hlines:persp_sf(LVCt::{{float(),float()} | {_,_,_},{float(),float()} | {_,_,_}}) will never return since it differs in the 1st argument from the success typing arguments: ({_,number()})
~omit ~
done in 0m4.21s
done (warnings were emitted)

So, I have read carefully the source.
Note: It is might be a misguided reasoning, because I'm not a programming expert.

Look at a Line around 486 from wpc_hlines.erl
Code:
        {Proj, Front_face, Side_face, Wvp, Hvp} =
        if
            Is_ortho ->
            {fun({X, Y, _Z}) -> {X, Y}; %% This fun() is binded to Proj
                ({{X1, Y1, _Z1}, {X2, Y2, _Z2}}) ->
                 {{X1, Y1}, {X2, Y2}}
             end,
             fun ortho_ff/1,
             fun ortho_sf/1,
             Distance * ARw / Flen,
             Distance * ARh / Flen}
                ;
            true ->
            {fun({X, Y, Z}) ->  %% This fun() is binded to Proj
                 Rz = case catch Zf / Z of
                      R when is_float(R) -> R; _ -> ?BIG end,
                 {X * Rz, Y * Rz};
                ({{X1, Y1, Z1}, {X2, Y2, Z2}}) ->
                 Rz_1 = case catch Zf / Z1 of
                        R1 when is_float(R1) -> R1; _ -> ?BIG end,
                 Rz_2 = case catch Zf / Z2 of
                        R2 when is_float(R2) -> R2; _ -> ?BIG end,
                 {{X1 * Rz_1, Y1 * Rz_1}, {X2 * Rz_2, Y2 * Rz_2}}
             end,
             fun persp_ff/1,
             fun persp_sf/1,  %% binded to Side_face
             ARw,
             ARh}
        end,

Note:The binded variable Proj( = defined by fun() an anonymous function in the tuple ) is replaced as follows

proj({X, Y, Z}) -> %some process% end;
proj({{X1, Y1, Z1}, {X2, Y2, Z2}}) -> %some process% end.

The error massage of an argument type "LVCt::{{float(),float()} | {_,_,_},{float(),float()} | {_,_,_}})"
In fact,LVCt took the two tuples or three tuples.
*LVCt* = {{0.7256575605567986,-0.6635543866848802,-13.425001504083214},
{1.3669827324774597,-0.014517512922733067,-15.204735518018442}}

Probably this means that the argument must be pass into Proj() originally.
But Dialyzer suggests the possibility of it pass into persp_sf/1 (with incorrect argument type)
I thought that If any exception occurred on the fun(), then data passed to function persp_sf/1.


Then,I've isolated the Proj(fun()) from the tuple.
It has changed in this way.
Code:
        Proj =
        if
            Is_ortho ->
            fun({X, Y, _Z}) -> {X, Y};
                ({{X1, Y1, _Z1}, {X2, Y2, _Z2}}) ->
                 {{X1, Y1}, {X2, Y2}}
             end
                ;
            true ->
            fun({X, Y, Z}) ->
                 Rz = case catch Zf / Z of
                      R when is_float(R) -> R; _ -> ?BIG end,
                 {X * Rz, Y * Rz};
                 ({{X1, Y1, Z1}, {X2, Y2, Z2}}) ->
                 Rz_1 = case catch Zf / Z1 of
                        R1 when is_float(R1) -> R1; _ -> ?BIG end,
                 Rz_2 = case catch Zf / Z2 of
                        R2 when is_float(R2) -> R2; _ -> ?BIG end,
                 {{X1 * Rz_1, Y1 * Rz_1}, {X2 * Rz_2, Y2 * Rz_2}}
             end
        end,

        {Front_face, Side_face, Wvp, Hvp} =
        if
            Is_ortho ->
             {fun ortho_ff/1,
             fun ortho_sf/1,
             Distance * ARw / Flen,
             Distance * ARh / Flen}
                ;
            true ->
            { fun persp_ff/1,
             fun persp_sf/1,
             ARw,
             ARh}
        end,

and using dialyzer once again.

Quote:$ dialyzer /Applications/Wings3D\ 2.0.2.app/Contents/Resources/lib/wings-2.0.2/plugins/import_export/wpc_hlines.beam
Checking whether the PLT /Users/*****/.dialyzer_plt is up-to-date... yes
Proceeding with analysis...
~omit ~
done in 0m4.83s
done (passed successfully)

The error message has been eliminated.
How about that?
--------
tkbd
dgud
Offline

Grumpy Dev
Posts: 692
Threads: 37
Joined: Nov 2012
#2
05-30-2016, 10:25 AM
Thanks for the analyse, sorry for the late answer, I read it before but never answered, I have forward the bug to the person who knows dialyzer better.
tkbd
Offline

Senior Member

Posts: 451
Threads: 115
Joined: Nov 2012
#3
06-02-2016, 10:03 AM
I don't mind the delay so much. Wink
And, I hope that you get a good clue about this bug.
Good Lucks!
dgud
Offline

Grumpy Dev
Posts: 692
Threads: 37
Joined: Nov 2012
#4
06-02-2016, 11:23 AM (This post was last modified: 06-02-2016, 11:23 AM by dgud.)
I changed the code as your suggestion and let the guys who know dialyzer fix their bugs :-)
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D - Powered by MyBB

Linear Mode
Threaded Mode