-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdlib: create an init function for records with complex default values #9373
Open
frazze-jobb
wants to merge
4
commits into
erlang:master
Choose a base branch
from
frazze-jobb:frazze/stdlib/erl_expand_records_create_init_function/OTP-19464
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+158
−46
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
544d835
stdlib: create an init function for records with complex default values
frazze-jobb 5bd3a4d
stdlib: fix review comments
frazze-jobb fc096c6
fix: throw warnings when record fields use previously bound variables
frazze-jobb 5e9f9b8
fix: output "record default value" instead of function rec_init$^
frazze-jobb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,7 +272,34 @@ | |
t() -> | ||
catch #{ok => ok || #r1{}}, | ||
ok. | ||
""" | ||
""", | ||
~""" | ||
-record(r0, {a=[X||X<-[cucumber,banan]], | ||
b=case {cucumber,banan} of X -> X; _ -> ok end, | ||
c=fun()->{X,_} = {cucumber,banan}, X end}). | ||
-record(r1, {a=[X||X<-[side_effect(a)]], | ||
b=[X||X<-[side_effect(b)]]}). | ||
side_effect(X) -> self() ! {side_effect, X}, ok. | ||
t() -> | ||
%% Test that X does not affect default initialization | ||
X = {yes, no}, | ||
{yes,no} = X, | ||
#r0{a=[cucumber,banan], b={cucumber,banan}, c=C} = #r0{}, | ||
cucumber = C(), | ||
%% Test that initialization is not done on fields to be initialized | ||
%% with other than the default. | ||
#r1{a=hello,b=[ok]}=#r1{a=hello}, | ||
Ok1 = receive | ||
{side_effect, b} -> ok; | ||
{side_effect, a} -> nok | ||
end, | ||
Ok2 = receive | ||
{side_effect, b} -> ok; | ||
{side_effect, a} -> nok | ||
after 100 -> ok | ||
end, | ||
Ok1 = Ok2 = ok. | ||
""" | ||
], | ||
run(Config, Ts), | ||
ok. | ||
|
@@ -825,7 +852,7 @@ | |
File = filename(Filename, Config), | ||
Opts = [export_all,return,{outdir,?privdir}|Opts0], | ||
ok = file:write_file(File, Test), | ||
{ok, _M, Ws} = compile:file(File, Opts), | ||
Check warning on line 855 in lib/stdlib/test/erl_expand_records_SUITE.erl
|
||
warnings(File, Ws). | ||
|
||
compile_file_mod(Config) -> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.