krestenkrab / triq

Trifork QuickCheck
http://krestenkrab.github.com/triq/
Apache License 2.0
281 stars 54 forks source link

Error using triq in Erlang 15 #25

Closed mcandre closed 11 years ago

mcandre commented 11 years ago

When I try to use triq in my Erlang 15 application, ios7crypt, I get a parse error.

Trace

1> c(ios7crypt).
ios7crypt.erl:none: error in parse transform 'triq_autoexport': {undef,
[{triq_autoexport,
parse_transform,
[[{attribute,1,file,
{"ios7crypt.erl",1}},
{attribute,3,module,
ios7crypt},
{attribute,4,author,
"andrew.pennebaker@gmail.com"},
{attribute,5,export,
[{encrypt,1},
{decrypt,1},
{main,1}]},
{attribute,1,file,
{"/usr/local/Cellar/erlang/R15B03-1/lib/erlang/lib/triq-0.1.0/include/triq.hrl",
1}},
{attribute,40,import,
{triq,
[{fails,1},{check,1}]}},
{attribute,65,import,
{triq_dom,
[{list,1},
{tuple,1},
{int,0},
{int,1},
{int,2},
{byte,0},
{real,0},
{sized,1},
{elements,1},
{any,0},
{atom,0},
{atom,1},
{choose,2},
{oneof,1},
{frequency,1},
{bool,0},
{char,0},
{return,1},
{vector,2},
{binary,1},
{binary,0},
{non_empty,1},
{resize,2},
{non_neg_integer,0},
{pos_integer,0},
{unicode_char,0},
{unicode_string,0},
{unicode_string,1},
{unicode_binary,0},
{unicode_binary,1},
{unicode_binary,2},
{unicode_characters,0},
{unicode_characters,1},
{bind,2},
{bindshrink,2},
{suchthat,2},
{pick,2},
{shrink,2},
{sample,1},
{sampleshrink,1},
{seal,1},
{open,1},
{peek,1},
{domain,3},
{shrink_without_duplicates,
1}]}},
{attribute,7,file,
{"ios7crypt.erl",7}},
{attribute,7,import,
{getopt,
[{usage,2},{parse,2}]}},
{attribute,8,import,
{escript,[{script_name,0}]}},
{attribute,9,import,
{lists,
[{nth,2},
{map,2},
{flatten,1},
{nthtail,2},
{any,2}]}},
{attribute,10,import,
{string,
[{concat,2},
{join,2},
{substr,3},
{to_integer,1}]}},
{attribute,11,import,
{crypto,[{exor,2}]}},
{function,24,key,2,
[{clause,24,
[{var,24,'_'},
{integer,24,0}],
[],
[{nil,24}]},
{clause,25,
[{var,25,'Seed'},
{var,25,'Length'}],
[],
[{cons,25,
{call,25,
{atom,25,nth},
[{op,25,'rem',
{op,25,'+',
{var,25,'Seed'},
{integer,25,1}},
{integer,25,53}},
{cons,25,
{integer,25,100},
{cons,25,
{integer,25,115},
{cons,25,
{integer,25,102},
{cons,25,
{integer,25,100},
{cons,25,
{integer,25,59},
{cons,25,
{integer,25,107},
{cons,25,
{integer,25,
102},
{cons,25,
{integer,25,
111},
{cons,25,
{integer,25,
65},
{cons,25,
{integer,
25,44},
{cons,25,
{integer,
25,46},
{cons,25,
{integer,
25,105},
{cons,25,
{integer,
25,121},
{cons,
25,
{integer,
25,101},
{cons,
25,
{integer,
25,
119},
{cons,
25,
{integer,
25,
114},
{cons,
25,
{integer,
25,
107},
{cons,
25,
{integer,
25,
108},
{cons,
25,
{integer,
25,
100},
{cons,
25,
{integer,
25,
74},
{cons,
25,
{integer,
25,
75},
{cons,
25,
{integer,
25,
68},
{cons,
25,
{integer,
25,
72},
{cons,
25,
{integer,
25,
83},
{cons,
25,
{integer, 
25,
85},
{cons,
25,
{integer,
25,
66},
{cons,
25,
{integer,
25,
115},
{cons,
25,
{integer,
25,
103}, 
{cons, 
25,
{integer,
25,
118},
{cons,
25,
{integer,
25, 
99},
{cons,
25, 
{integer,
25,
97},
{cons,
25,
{integer,
25,
54},
{cons,
25,
{integer,
25,
57},
{cons,
25,
{integer,
25,
56},
{cons,
25,
{integer,
25,
51},
{cons,
25,
{integer,
25,
52},
{cons,
25,
{integer,
25,
110},
{cons,
25,
{integer,
25,
99},
{cons,
25,
{integer,
25,
120},
{cons,
25,
{integer,
25,
118},
{cons,
25,
{integer,
25,
57},
{cons,
25,
{integer,
25,
56},
{cons,
25,
{integer,
25,
55},
{cons,
25,
{integer,
25,
51},
{cons,
25,
{integer,
25,
50},
{cons,
25,
{integer,
25,
53},
{cons,
25,
{integer,
25,
52},
{cons,
25,
{integer,
25,
107},
{cons,
25,
{integer,
25,
59},
{cons,
25,
{integer,
25,
102},
{cons,
25,
{integer,
25,
103},
{cons,
25,
{integer,
25,
56},
{cons,
25,
{integer,
25,
55},
{nil,
25}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]},
{call,25,
{atom,25,key},
[{op,25,'+',
{var,25,'Seed'},
{integer,25,1}},
{op,25,'-',
{var,25,'Length'},
{integer,25,
1}}]}}]}]},
{function,27,encrypt,1,
[{clause,27,
[{var,27,'Password'}],
[],
[{match,28,
{var,28,'Seed'},
{op,28,'-',
{call,28,
{remote,28,
{atom,28,random},
{atom,28,uniform}},
[{integer,28,16}]},
{integer,28,1}}},
{match,29,
{var,29,'Key'},
{call,29,
{atom,29,key},
[{var,29,'Seed'},
{call,29,
{atom,29,length},
[{var,29,
'Password'}]}]}},
{match,30,
{var,30,'CipherText'},
{call,30,
{atom,30,
binary_to_list},
[{call,30,
{atom,30,exor},
[{var,30,'Password'},
{var,30,'Key'}]}]}},
{match,34,
{var,34,'Rest'},
{call,34,
{atom,34,flatten},
[{call,34,
{atom,34,map},
[{'fun',34,
{clauses,
[{clause,34,
[{var,34,'A'}],
[],
[{call,34,
{remote,34,
{atom,34,
io_lib},
{atom,34,
format}},
[{string,34,
"~2.16.0b"},
{cons,34,
{var,34,'A'},
{nil,
34}}]}]}]}},
{var,34,
'CipherText'}]}]}},
{call,36,
{atom,36,concat},
[{call,36,
{atom,36,flatten},
[{call,36,
{remote,36,
{atom,36,io_lib},
{atom,36,format}},
[{string,36,
"~2.10.0b"},
{cons,36,
{var,36,'Seed'},
{nil,36}}]}]},
{var,36,'Rest'}]}]}]},
{function,38,onlyPairs,1,
[{clause,38,
[{var,38,'Text'}],
[],
[{cons,38,
{call,38,
{atom,38,substr},
[{var,38,'Text'},
{integer,38,1},
{integer,38,2}]},
{'case',39,
{op,39,'=<',
{call,39,
{atom,39,length},
[{var,39,'Text'}]},
{integer,39,3}},
[{clause,40,
[{atom,40,true}],
[],
[{nil,40}]},
{clause,41,
[{atom,41,false}],
[],
[{call,41,
{atom,41,onlyPairs},
[{call,41,
{atom,41,substr},
[{var,41,'Text'},
{integer,41,3},
{call,41,
{atom,41,
length},
[{var,41,
'Text'}]}]}]}]}]}}]}]},
{function,44,decrypt,1,
[{clause,44,
[{var,44,'Hash'}],
[[{op,44,'<',
{call,44,
{atom,44,length},
[{var,44,'Hash'}]},
{integer,44,4}}]],
[{tuple,44,
[{atom,44,ok},
{string,44,[]}]}]},
{clause,45,
[{var,45,'Hash'}],
[],
[{match,46,
{var,46,'FirstTwo'},
{call,46,
{atom,46,substr},
[{var,46,'Hash'},
{integer,46,1},
{integer,46,2}]}},
{match,48,
{var,48,'FirstOneRaw'},
{call,48,
{remote,48,
{atom,48,re},
{atom,48,replace}},
[{var,48,'FirstTwo'},
{string,48,"^0"},
{string,48,[]}]}},
{match,50,
{var,50,'FirstTemp'},
{call,50,
{atom,50,nthtail},
[{integer,50,1},
{var,50,
'FirstOneRaw'}]}},
{match,52,
{var,52,'FirstOne'},
{'case',52,
{call,52,
{atom,52,is_binary},
[{var,52,
'FirstTemp'}]},
[{clause,53,
[{atom,53,true}],
[],
[{call,53,
{atom,53,
binary_to_list},
[{var,53,
'FirstTemp'}]}]},
{clause,54,
[{atom,54,false}],
[],
[{var,54,
'FirstOneRaw'}]}]}},
{match,57,
{var,57,'ToInt'},
{'catch',57,
{call,57,
{atom,57,
list_to_integer},
[{var,57,'FirstOne'},
{integer,57,10}]}}},
{'case',59,
{var,59,'ToInt'},
[{clause,60,
[{atom,60,badarg}],
[],
[{tuple,61,
[{atom,61,error},
{atom,61,
invalid_hash}]}]},
{clause,62,
[{var,62,'S'}],
[],
[{match,63,
{var,63,'H'},
{call,63,
{atom,63,onlyPairs},
[{call,63,
{atom,63,substr},
[{var,63,'Hash'},
{integer,63,3},
{call,63,
{atom,63,
length},
[{var,63,
'Hash'}]}]}]}},
{match,65,
{var,65,
'CipherText'},
{'catch',65,
{call,65,
{atom,65,map},
[{'fun',65,
{clauses,
[{clause,65,
[{var,65,
'Pair'}],
[],
[{call,65,
{atom,65,
list_to_integer},
[{var,65,
'Pair'},
{integer,
65,
16}]}]}]}},
{var,65,'H'}]}}},
{'case',67,
{var,67,
'CipherText'},
[{clause,68,
[{tuple,68,
[{atom,68,
'EXIT'},
{tuple,68,
[{atom,68,
badarg},
{var,68,
'_'}]}]}],
[],
[{tuple,69,
[{atom,69,error},
{atom,69,
invalid_hash}]}]},
{clause,70,
[{var,70,'_'}],
[],
[{match,71,
{var,71,'Key'},
{call,71,
{atom,71,key},
[{var,71,'S'},
{call,71,
{atom,71,
length},
[{var,71,
'CipherText'}]}]}},
{tuple,72,
[{atom,72,ok},
{call,72,
{atom,72,
binary_to_list},
[{call,72,
{atom,72,
exor},
[{var,72,
'CipherText'},
{var,72,
'Key'}]}]}]}]}]}]}]}]}]},
{function,76,
prop_reversible,0,
[{clause,76,[],[],
[{tuple,77,
[{atom,77,'prop:forall'},
{tuple,77,
[{call,77,
{atom,77,list},
[{call,77,
{atom,77,int},
[]}]}]},
{string,77,
"{ Password }"},
{'fun',77,
{clauses,
[{clause,77,
[{tuple,77,
[{var,77,
'Password'}]}],
[],
[{block,77,
[{'case',79,
{call,79,
{atom,79,any},
[{'fun',79,
{clauses,
[{clause,
79,
[{var,
79,
'X'}],
[],
[{op,79,
'<',
{var,
79,
'X'},
{integer,
79,
0}}]}]}},
{var,79,
'Password'}]},
[{clause,80,
[{atom,80,
true}],
[],
[{atom,80,
true}]},
{clause,81,
[{atom,81,
false}],
[],
[{'case',81,
{call,81,
{remote,
81,
{atom,
81,
ios7crypt},
{atom,
81,
decrypt}},
[{call,
81,
{remote,
81,
{atom,
81,
ios7crypt},
{atom,
81,
encrypt}},
[{var,
81,
'Password'}]}]},
[{clause,
82,
[{tuple,
82,
[{atom,
82,
error},
{var,
82,
'_'}]}],
[],
[{atom,
82,
false}]},
{clause,
83,
[{tuple,
83,
[{atom,
83,
ok},
{var,
83,
'Password2'}]}],
[],
[{op,83,
'==',
{var,
83,
'Password2'},
{var,
83,
'Password'}}]}]}]}]}]}]}]}},
{string,85,
"case any ( fun ( X ) -> X < 0 end , Password ) of true -> true ; false -> case ios7crypt : decrypt ( ios7crypt : encrypt ( Password ) ) of { error , _ } -> false ; { ok , Password2 } -> Password2 == Password end end"}]}]}]},
{function,87,option_spec,0,
[{clause,87,[],[],
[{cons,88,
{tuple,90,
[{atom,90,encrypt},
{char,90,101},
{string,90,"encrypt"},
{atom,90,string},
{string,90,
"Encrypt a password"}]},
{cons,91,
{tuple,91,
[{atom,91,decrypt},
{char,91,100},
{string,91,"decrypt"},
{atom,91,string},
{string,91,
"Decrypt a hash"}]},
{cons,92,
{tuple,92,
[{atom,92,test},
{char,92,116},
{string,92,"test"},
{atom,92,undefined},
{string,92,
"Perform unit test"}]},
{cons,93,
{tuple,93,
[{atom,93,help},
{char,93,104},
{string,93,"help"},
{atom,93,undefined},
{string,93,
"Display usage information"}]},
{nil,94}}}}}]}]},
{function,96,u,0,
[{clause,96,[],[],
[{call,96,
{atom,96,usage},
[{call,96,
{atom,96,option_spec},
[]},
{call,96,
{atom,96,script_name},
[]}]}]}]},
{function,98,main,1,
[{clause,98,
[{nil,98}],
[],
[{call,98,
{atom,98,u},
[]}]},
{clause,99,
[{var,99,'Args'}],
[],
[{match,100,
{tuple,100,
[{var,100,'A1'},
{var,100,'A2'},
{var,100,'A3'}]},
{call,100,
{atom,100,now},
[]}},
{call,101,
{remote,101,
{atom,101,random},
{atom,101,seed}},
[{var,101,'A1'},
{var,101,'A2'},
{var,101,'A3'}]},
{'case',103,
{call,103,
{atom,103,parse},
[{call,103,
{atom,103,
option_spec},
[]},
{var,103,'Args'}]},
[{clause,104,
[{tuple,104,
[{atom,104,error},
{var,104,'_'}]}],
[],
[{call,104,
{atom,104,u},
[]}]},
{clause,106,
[{tuple,106,
[{atom,106,ok},
{tuple,106,
[{var,106,
'Options'},
{var,106,
'_'}]}]}],
[],
[{'case',107,
{call,107,
{atom,107,nth},
[{integer,107,1},
{var,107,
'Options'}]},
[{clause,108,
[{atom,108,help}],
[],
[{call,108,
{atom,108,u},
[]}]},
{clause,109,
[{atom,109,test}],
[],
[{call,109,
{remote,109,
{atom,109,triq},
{atom,109,
check}},
[{call,109,
{atom,109,
prop_reversible},
[]}]}]},
{clause,111,
[{tuple,111,
[{atom,111,
encrypt},
{var,111,
'Password'}]}],
[],
[{call,112,
{remote,112,
{atom,112,io},
{atom,112,
format}},
[{string,112,
"~s~n"},
{cons,112,
{call,112,
{atom,112,
encrypt},
[{var,112,
'Password'}]},
{nil,112}}]}]},
{clause,113,
[{tuple,113,
[{atom,113,
decrypt},
{var,113,
'Hash'}]}],
[],
[{'case',114,
{call,114,
{atom,114,
decrypt},
[{var,114,
'Hash'}]},
[{clause,115,
[{tuple,115,
[{atom,115,
ok},
{var,115,
'Password'}]}],
[],
[{call,115,
{remote,
115,
{atom,115,
io},
{atom,115,
format}},
[{string,
115,
"~s~n"},
{cons,115,
{var,115,
'Password'},
{nil,
115}}]}]},
{clause,116,
[{var,116,
'_'}],
[],
[{call,116,
{remote,
116,
{atom,116,
io},
{atom,116,
format}},
[{string,
116,
"Invalid hash.~n"}]}]}]}]}]}]}]}]}]},
{eof,119}],
[report_errors,
report_warnings]],
[]},
{compile,
'-foldl_transform/2-anonymous-2-',
2,
[{file,"compile.erl"},
{line,847}]},
{compile,foldl_transform,2,
[{file,"compile.erl"},
{line,849}]},
{compile,
'-internal_comp/4-anonymous-1-',
2,
[{file,"compile.erl"},
{line,273}]},
{compile,fold_comp,3,
[{file,"compile.erl"},
{line,291}]},
{compile,internal_comp,4,
[{file,"compile.erl"},
{line,275}]},
{compile,
'-do_compile/2-anonymous-0-',2,
[{file,"compile.erl"},
{line,152}]}]}

System

$ specs erlang
Specs:

specs 0.4
https://github.com/mcandre/specs#readme

rebar -V
rebar 2.1.0-pre R15B03 20130528_213220 git 2.1.0-pre-46-g78fa8fc

erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
"R15B03"
ghost commented 11 years ago

Any specific steps to reproduce? I did a quick test with R15B03 and it didn't fail for me.

mcandre commented 11 years ago

Were you able to integrate triq into ios7crypt, my example app?

ghost commented 11 years ago

I successfully compiled first triq and then ios7crypt.erl with R15B03 after reverting mcandre/ios7crypt@2b81fd964. triq's unit tests also passed.

mcandre commented 11 years ago

Okay, this is bizarre. Suddenly and for no reason, with the same specs on my machine, compiling works again.