about summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
...
* Readme: add config location of MacOSReto Brunner2020-04-121-1/+2
|
* msg/archive: complete the possible optionsReto Brunner2020-04-112-1/+17
|
* README: include demo and update required go versionReto Brunner2020-04-071-1/+3
|
* go mod tidy, updated go.sumReto Brunner2020-04-061-0/+13
|
* Try to open attachments with correct extensionGalen Abell2020-04-061-1/+13
| | | | | | The temporary file created when opening an attachment is currently saved without an extension, which prevents matching on file ending with xdg-open.
* fix function keys in terminal widgetJonathan Halmen2020-03-261-1/+1
| | | | off-by-one error
* Requires Go 1.13Simon Ser2020-03-201-1/+1
| | | | We use errors.Is, which has been introduced in Go 1.13.
* msgviewer: do not interpret header as format stringDrew DeVault2020-03-191-2/+2
|
* Add quotes to the default pinned-tab-markerZoltan Kalmar2020-03-131-1/+1
| | | | | | | | | | It's a fix for: https://todo.sr.ht/~sircmpwn/aerc2/361 Using an unquoted backtick char is leading to a config error: ``` Failed to load config: missing closing key quote from '` ' to '' ```
* Add pinned tabsJeffas2020-03-096-6/+119
| | | | | | This adds the commands pin-tab and unpin-tab. Once pinned a tab lives on the left of the tabstrip and has a configurable marker, defaulting to ` before its name.
* Correct the khard example so that it works with aercPeter Lamby2020-03-091-1/+1
|
* Mark sent messages as "seen" in maildirGalen Abell2020-03-091-1/+0
| | | | | | | - Add maildir flags to complement a messages imap flags - Set the "seen" flag on sent messages when using the maildir backend - Cleanup AppendMessage interface to use models.Flag for both IMAP and maildir
* Count recent messages in maildir exists total tooJeffas2020-03-091-1/+1
|
* Ignore missing message part in getDecodedPartAmir Yalon2020-03-091-1/+1
| | | | The code that calls this function handles nil without issues.
* Refactoring: remove store from PartInfoDrew DeVault2020-03-095-5/+6
|
* go.sum: re-add notmuchReto Brunner2020-03-051-0/+1
|
* Reduce size of the password prompt UIDrew DeVault2020-03-031-2/+2
|
* Yet another revision to PGP UIDrew DeVault2020-03-031-4/+4
| | | | I think this will be the one.
* Simplify PGP messagingDrew DeVault2020-03-031-20/+11
|
* compose: add space between headers and editorDrew DeVault2020-03-031-3/+5
| | | | Until the PGP changes, this was merged into the header widget.
* Initial support for PGP decryption & signaturesDrew DeVault2020-03-0317-82/+523
|
* Update dependenciesSimon Ser2020-03-033-74/+66
| | | | This brings in some bug fixes.
* worker/imap: rely on go-imap for charset handlingSimon Ser2020-03-031-31/+13
| | | | | Set imap.CharsetReader so that go-imap can automatically decode all encoded fields.
* Mark sent messages as "seen" in maildirGalen Abell2020-03-0310-21/+65
| | | | | | | - Add maildir flags to complement a messages imap flags - Set the "seen" flag on sent messages when using the maildir backend - Cleanup AppendMessage interface to use models.Flag for both IMAP and maildir
* Add move-tab commandJeffas2020-03-034-0/+108
|
* Document smtp-starttlsPeter Lamby2020-03-021-0/+4
|
* notmuch: emit dirinfo upon label changeReto Brunner2020-03-011-0/+3
|
* remove the dirInfoUpdateRequest functionalityReto Brunner2020-02-293-24/+0
| | | | | The notmuch worker followed suit in handling the dirInfo submission manually. That removes the last user so we might as well remove the functionality.
* notmuch: align dirInfo logic to the maildir workerReto Brunner2020-02-291-10/+13
|
* msg/delete: remove redundant err checkReto Brunner2020-02-291-3/+0
|
* Only show spinner while sorting if no uidsJeffas2020-02-281-7/+7
| | | | | This fixes the problem where we already have messages and then have to sort again.
* Don't show empty message while sortingJeffas2020-02-282-4/+14
| | | | | | This changes the ui to show the spinner while we are sorting. It only shows one line of the spinner since there are an unknown number of messages at this time.
* Set the store on the message list if it is nilJeffas2020-02-281-0/+3
|
* Cleanup sorting logicJeffas2020-02-281-155/+55
| | | | | | There was an unused error value as well as unnecessary usage of the sort interface. There should now be less copying so a bit better performance in some cases.
* Don't set the store on an update to itJeffas2020-02-281-4/+0
| | | | | | Updates to a store can be asynchronous so we shouldn't select it just because it had an update. Selection of the stores should be driven by explicit user commands.
* Update DirectoryInfo handling for maildirJeffas2020-02-281-6/+50
| | | | | | | | | | | This ensures that the directory info is up to date on events in the maildir worker. This also sets up the initial dirinfo for other directories and updates them when using built-in commands. FS events are still only watched for the selected directory. This should be changed in a future patch to watch other directories too in order to cover UI updates for folders when an event occurs in a non-selected folder.
* Make search more lenientJeffas2020-02-261-1/+2
| | | | | When we fail to read a single message we don't need to fail the whole search, just log the error and we can still get results back.
* Add missing notmuch build tagsJeffas2020-02-262-0/+4
|
* note in aerc-templates.7.scd for toLocal functionsqwishy2020-02-251-0/+7
|
* Ensure new directory exists before unwatching oldGalen Abell2020-02-251-5/+6
|
* toLocal template functionsqwishy2020-02-252-1/+6
| | | | | | | | | | Hi. This adds a template function to convert a time to the local time zone. And modifies the default quoted_reply template to use it and show the time zone when formatting the timestamp of the quoted message. Previously, the quoted message timestamp was UTC and it would format it without the time zone. And I thought it might be a little confusing or weird to some normal people when I email them and I don't want normal people to be confused or think that I'm weird.
* lib/msgstore: debounce directoryUpdateRequestsReto Brunner2020-02-252-3/+19
| | | | | | | | Apparently sending an event for every incoming messageInfo slows down the application significantly. Therefore this slows down the emmision rate, on the cost of being out of date in some cases.
* widgets/dirlist: Fix total message countReto Brunner2020-02-251-4/+6
| | | | | | | | | This fixes an issue with the updated count logic, where only fetched messages where counted to the exists string of the rue count. Note that the count is still broken (we only count read / unread messages we fetched, but that is the same behaviour as prior to the commit 66b68f35b3f3f3b97ec9951397fd75afeb0d0995)
* Fix crash on mouse scrolling between message partsAmir Yalon2020-02-251-2/+2
|
* Fix crash on mouse scrolling before messages loadWiktor Kwapisiewicz2020-02-221-2/+6
| | | | | Using mouse scroll before messages load will trigger a panic as `ml.store` has not been assigned yet and is `nil`.
* fix missing importReto Brunner2020-02-191-0/+1
|
* Revert "Only fetch the directory contents when we are switching directories"Reto Brunner2020-02-193-6/+9
| | | | | | | This reverts commit bd4df530095ee343778a59120a9e641c01010b0f. I did not properly untangle the opening / dirlist update of each other. This interferes with the imap worker, hence the revert
* msg/reply: simplify string comparisonReto Brunner2020-02-191-1/+1
|
* msg/reply: fix address comparisonReto Brunner2020-02-161-1/+1
| | | | | | | Compare self address in lowercase, to avoid self-replying when people put in uppercase versions of the mail. Reported-By: helby on Freenode
* notmuch: refresh dirlist in backgroundReto Brunner2020-02-163-1/+27
|
mp;id=1d079fc574a35f39fd52e3de23a1c8bfa45238ae'>^
dea90217 ^
67db19a0 ^
4690ce81 ^
2f02189d ^
67db19a0 ^

d059fe74 ^
2f02189d ^

dea90217 ^
4690ce81 ^
2f02189d ^
44c1aeef ^
67db19a0 ^




d059fe74 ^
4690ce81 ^
67db19a0 ^
44c1aeef ^
2f02189d ^
67db19a0 ^

a654e4ec ^
4690ce81 ^
a654e4ec ^
d009e158 ^

4690ce81 ^
2f02189d ^
dcc060c7 ^
67db19a0 ^

4690ce81 ^
67db19a0 ^



dea90217 ^
76755b28 ^
3e1349d2 ^
f344b250 ^
76755b28 ^
3e1349d2 ^
f344b250 ^

76755b28 ^
4690ce81 ^
76755b28 ^
f344b250 ^
76755b28 ^
9a81d746 ^
672e3e50 ^
9a81d746 ^



65361948 ^
dea90217 ^
76755b28 ^
3e1349d2 ^
f344b250 ^

672e3e50 ^
3e1349d2 ^
f344b250 ^

672e3e50 ^
f344b250 ^
672e3e50 ^
dea90217 ^
3e1349d2 ^
f344b250 ^

d5d908dd ^
3e1349d2 ^
f344b250 ^

d5d908dd ^
76755b28 ^
d5d908dd ^
672e3e50 ^
4690ce81 ^

672e3e50 ^
4690ce81 ^
76755b28 ^
672e3e50 ^


d059fe74 ^
4690ce81 ^
76755b28 ^
672e3e50 ^






a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199



                                                                                          
                                    

                                                
                                  

                                                                                         

                       
                                                                                                 
                                                                                            

                                      
                             
                             
                            

                              
                                  
                                                                           
                               

        





                               

       
                         
                                                                                             
 
                                                 
                                        
                                                                                                                                                                               
 
                                     


                                                                                                                                                                                  
 

                                                                 

                                                                                      
                                      
                                                                                 

                                                                                                                                                                                                                                                                 
                                                                                
                                                                         
                                                                                                                                                      
                                
                                                                                         
                                                                         
                                                
                                                                                                                                              

                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                        


                                                                                                                                     
                                  

                                                                                                                                     
                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                         
                                                                                                                                                                                                                                                                                                                                                                            
                                           
                                                                                                                                                         

                                


                                                                                       
                                                                                                                                                                                                
                                      
                                                                                                                                                                                                                     
                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                    




                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                     
                                                                                                                                                                                                                                           
                                                                 
                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                      

                                                                             
                                                                                                                                                                                                                                                                                                                                                                                       

                                                                                                                                                                                                                                                                                   
                                                                       
                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        




                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

                                                                                                   
                                                                                                                                                                                    
                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

                                                                                                   
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                          

                                        
                                                                                     



                                    
                                                               
                                                  
                                        
                                                                                                          
 
                                     

                                                                                                               
                                                                                                                                                        
                                                                               
 
                                                                                                    
 
                                                                                                  
                                                                                                         



                                                                                                    
 
                                                                    
                                                  
                                        

                                                                                                                                                                                             
 
                                         

                                                                                                                                
 
                                                                                                                      
 
                                                                          
                                        

                                                                                                                                                           
 
                                         

                                                                                                                                
 
                                       
 
                                      

                                                                                                                                                                                                                                                              
                                                   
                                                                                                                                                                                                                                           
                                                                                                                                                                                                   


                                                                                                                   
                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                   
                                                                                                                                                                     






                                                                                                                 
                                     
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 028call_reply.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 12pt; font-size: 1em; }
.Constant { color: #00a0a0; }
.cSpecial { color: #008000; }
.muRecipe { color: #ff8700; }
.Comment { color: #9090ff; }
.Delimiter { color: #800080; }
.Special { color: #c00000; }
.traceContains { color: #008000; }
.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; }
.Identifier { color: #c0a020; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">//: Calls can also generate products, using 'reply' or 'return'.</span>

<span class="Delimiter">:(scenario return)</span>
<span class="muRecipe">def</span> main [
  <span class="Constant">1</span>:num<span class="Delimiter">,</span> <span class="Constant">2</span>:num<span class="Special"> &lt;- </span>f <span class="Constant">34</span>
]
<span class="muRecipe">def</span> f [
  <span class="Constant">12</span>:num<span class="Special"> &lt;- </span>next-ingredient
  <span class="Constant">13</span>:num<span class="Special"> &lt;- </span>add <span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">12</span>:num
  reply <span class="Constant">12</span>:num<span class="Delimiter">,</span> <span class="Constant">13</span>:num
]
<span class="traceContains">+mem: storing 34 in location 1</span>
<span class="traceContains">+mem: storing 35 in location 2</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
RETURN<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;return&quot;</span><span class="Delimiter">,</span> RETURN<span class="Delimiter">);</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;reply&quot;</span><span class="Delimiter">,</span> RETURN<span class="Delimiter">);</span>  <span class="Comment">// synonym while teaching</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> RETURN: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>  <span class="Comment">// checks will be performed by a transform below</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> RETURN: <span class="Delimiter">{</span>
  <span class="Comment">// Starting Reply</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">&quot;trace&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;reply: decrementing callstack depth from &quot;</span> &lt;&lt; Trace_stream<span class="Delimiter">-&gt;</span>callstack_depth &lt;&lt; end<span class="Delimiter">();</span>
    --Trace_stream<span class="Delimiter">-&gt;</span>callstack_depth<span class="Delimiter">;</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-&gt;</span>callstack_depth &lt; <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
      Current_routine<span class="Delimiter">-&gt;</span>calls<span class="Delimiter">.</span>clear<span class="Delimiter">();</span>
      <span class="Identifier">goto</span> stop_running_current_routine<span class="Delimiter">;</span>
    <span class="Delimiter">}</span>
  <span class="Delimiter">}</span>
  Current_routine<span class="Delimiter">-&gt;</span>calls<span class="Delimiter">.</span>pop_front<span class="Delimiter">();</span>
  <span class="Comment">// just in case 'main' returns a value, drop it for now</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-&gt;</span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">goto</span> stop_running_current_routine<span class="Delimiter">;</span>
  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span>  i &lt; SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span>
    trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;result &quot;</span> &lt;&lt; i &lt;&lt; <span class="Constant">&quot; is &quot;</span> &lt;&lt; to_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Comment">// make reply products available to caller</span>
  copy<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> ingredients<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> inserter<span class="Delimiter">(</span>products<span class="Delimiter">,</span> products<span class="Delimiter">.</span>begin<span class="Delimiter">()));</span>
  <span class="Comment">// End Reply</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>  <span class="Comment">// continue to process rest of *caller* instruction</span>
<span class="Delimiter">}</span>

<span class="Comment">//: Types in reply instructions are checked ahead of time.</span>

<span class="Delimiter">:(before &quot;End Checks&quot;)</span>
Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_types_of_reply_instructions<span class="Delimiter">);</span>  <span class="Comment">// idempotent</span>
<span class="Delimiter">:(code)</span>
<span class="Normal">void</span> check_types_of_reply_instructions<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  <span class="Normal">const</span> recipe&amp; caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span>
  trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;--- check types of reply instructions in recipe &quot;</span> &lt;&lt; caller<span class="Delimiter">.</span>name &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span>  i &lt; SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    <span class="Normal">const</span> instruction&amp; caller_instruction = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>operation &lt; MAX_PRIMITIVE_RECIPES<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
    <span class="Normal">const</span> recipe&amp; callee = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> caller_instruction<span class="Delimiter">.</span>operation<span class="Delimiter">);</span>
    <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span>  i &lt; SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>steps<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
      <span class="Normal">const</span> instruction&amp; reply_inst = callee<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>operation != RETURN<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
      <span class="Comment">// check types with the caller</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">)</span> &gt; SIZE<span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span>
        raise &lt;&lt; maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;too few values returned from &quot;</span> &lt;&lt; callee<span class="Delimiter">.</span>name &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
        <span class="Identifier">break</span><span class="Delimiter">;</span>
      <span class="Delimiter">}</span>
      <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span>  i &lt; SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
        reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> lhs = reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
        reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> rhs = caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
        <span class="Comment">// End Check RETURN Copy(lhs, rhs)</span>
        <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>rhs<span class="Delimiter">,</span> lhs<span class="Delimiter">))</span> <span class="Delimiter">{</span>
          raise &lt;&lt; maybe<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; reply_inst<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot; ingredient '&quot;</span> &lt;&lt; lhs<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;' can't be saved in '&quot;</span> &lt;&lt; rhs<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
          raise &lt;&lt; <span class="Constant">&quot;  ['&quot;</span> &lt;&lt; to_string<span class="Delimiter">(</span>lhs<span class="Delimiter">.</span>type<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;' vs '&quot;</span> &lt;&lt; to_string<span class="Delimiter">(</span>rhs<span class="Delimiter">.</span>type<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;']</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
          <span class="Identifier">goto</span> finish_reply_check<span class="Delimiter">;</span>
        <span class="Delimiter">}</span>
      <span class="Delimiter">}</span>
      <span class="Comment">// check that any reply ingredients with /same-as-ingredient connect up</span>
      <span class="Comment">// the corresponding ingredient and product in the caller.</span>
      <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span>  i &lt; SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
        <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">&quot;same-as-ingredient&quot;</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
          string_tree* tmp = property<span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">&quot;same-as-ingredient&quot;</span><span class="Delimiter">);</span>
          <span class="Normal">if</span> <span class="Delimiter">(</span>!tmp || !tmp<span class="Delimiter">-&gt;</span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span>
            raise &lt;&lt; maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'same-as-ingredient' metadata should take exactly one value in '&quot;</span> &lt;&lt; to_original_string<span class="Delimiter">(</span>reply_inst<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
            <span class="Identifier">goto</span> finish_reply_check<span class="Delimiter">;</span>
          <span class="Delimiter">}</span>
          <span class="Normal">int</span> ingredient_index = to_integer<span class="Delimiter">(</span>tmp<span class="Delimiter">-&gt;</span>value<span class="Delimiter">);</span>
          <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_index &gt;= SIZE<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span>
            raise &lt;&lt; maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;too few ingredients in '&quot;</span> &lt;&lt; to_original_string<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
            <span class="Identifier">goto</span> finish_reply_check<span class="Delimiter">;</span>
          <span class="Delimiter">}</span>
          <span class="Normal">if</span> <span class="Delimiter">(</span>!is_dummy<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> &amp;&amp; !is_literal<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">))</span> &amp;&amp; caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name != caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>name<span class="Delimiter">)</span> <span class="Delimiter">{</span>
            raise &lt;&lt; maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'&quot;</span> &lt;&lt; to_original_string<span class="Delimiter">(</span>caller_instruction<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;' should write to '&quot;</span> &lt;&lt; caller_instruction<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;' rather than '&quot;</span> &lt;&lt; caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
          <span class="Delimiter">}</span>
        <span class="Delimiter">}</span>
      <span class="Delimiter">}</span>
      <span class="Normal">finish_reply_check</span>:<span class="Delimiter">;</span>
    <span class="Delimiter">}</span>
  <span class="Delimiter">}</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(scenario return_type_mismatch)</span>
<span class="Special">% Hide_errors = true;</span>
<span class="muRecipe">def</span> main [
  <span class="Constant">3</span>:num<span class="Special"> &lt;- </span>f <span class="Constant">2</span>
]
<span class="muRecipe">def</span> f [
  <span class="Constant">12</span>:num<span class="Special"> &lt;- </span>next-ingredient
  <span class="Constant">13</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
  <span class="Constant">14</span>:point<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>:point/<span class="Special">raw</span>
  <span class="Identifier">return</span> <span class="Constant">14</span>:point
]
<span class="traceContains">+error: f: return ingredient '14:point' can't be saved in '3:num'</span>

<span class="Comment">//: In Mu we'd like to assume that any instruction doesn't modify its</span>
<span class="Comment">//: ingredients unless they're also products. The /same-as-ingredient inside</span>
<span class="Comment">//: the recipe's 'reply' indicates that an ingredient is intended to be</span>
<span class="Comment">//: modified in place, and will help catch accidental misuse of such</span>
<span class="Comment">//: 'ingredient-products' (sometimes called in-out parameters in other</span>
<span class="Comment">//: languages).</span>

<span class="Delimiter">:(scenario return_same_as_ingredient)</span>
<span class="Special">% Hide_errors = true;</span>
<span class="muRecipe">def</span> main [
  <span class="Constant">1</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
  <span class="Constant">2</span>:num<span class="Special"> &lt;- </span>test1 <span class="Constant">1</span>:num  <span class="Comment"># call with different ingredient and product</span>
]
<span class="muRecipe">def</span> test1 [
  <span class="Constant">10</span>:num<span class="Special"> &lt;- </span>next-ingredient
  <span class="Identifier">return</span> <span class="Constant">10</span>:num/same-as-ingredient:<span class="Constant">0</span>
]
<span class="traceContains">+error: main: '2:num &lt;- test1 1:num' should write to '1:num' rather than '2:num'</span>

<span class="Delimiter">:(scenario return_same_as_ingredient_dummy)</span>
<span class="muRecipe">def</span> main [
  <span class="Constant">1</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
  _<span class="Special"> &lt;- </span>test1 <span class="Constant">1</span>:num  <span class="Comment"># call with different ingredient and product</span>
]
<span class="muRecipe">def</span> test1 [
  <span class="Constant">10</span>:num<span class="Special"> &lt;- </span>next-ingredient
  <span class="Identifier">return</span> <span class="Constant">10</span>:num/same-as-ingredient:<span class="Constant">0</span>
]
$error: <span class="Constant">0</span>

<span class="Delimiter">:(code)</span>
string to_string<span class="Delimiter">(</span><span class="Normal">const</span> vector&lt;<span class="Normal">double</span>&gt;&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">&quot;[]&quot;</span><span class="Delimiter">;</span>
  ostringstream out<span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>in<span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    out &lt;&lt; no_scientific<span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span>
    <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span>
  <span class="Delimiter">}</span>
  out &lt;&lt; <span class="Constant">&quot;[&quot;</span><span class="Delimiter">;</span>
  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span>  i &lt; SIZE<span class="Delimiter">(</span>in<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>i &gt; <span class="Constant">0</span><span class="Delimiter">)</span> out &lt;&lt; <span class="Constant">&quot;, &quot;</span><span class="Delimiter">;</span>
    out &lt;&lt; no_scientific<span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span>
  <span class="Delimiter">}</span>
  out &lt;&lt; <span class="Constant">&quot;]&quot;</span><span class="Delimiter">;</span>
  <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span>
<span class="Delimiter">}</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->