summary refs log tree commit diff stats
path: root/compiler/modulegraphs.nim
Commit message (Collapse)AuthorAgeFilesLines
* Initial implementation of nimsuggest v3 (#19826)Ivan Yonchovski2022-06-131-13/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial implementation of nimsuggest v3 Rework `nimsuggest` to use caching to make usage of ide commands more efficient. Previously, all commands no matter what the state of the process is were causing clean build. In the context of Language Server Protocol(LSP) and lsp clients this was causing perf issues and overall instability. Overall, the goal of v3 is to fit to LSP Server needs - added two new commands: - `recompile` to do clean compilation - `changed` which can be used by the IDEs to notify that a particular file has been changed. The later can be utilized when using LSP file watches. - `globalSymbols` - searching global references - added `segfaults` dependency to allow fallback to clean build when incremental fails. I wish the error to be propagated to the client so we can work on fixing the incremental build failures (typically hitting pointer) - more efficient rebuild flow. ATM incremental rebuild is triggered when the command needs that(i. e. it is global) while the commands that work on the current source rebuild only it Things missing in this PR: - Documentation - Extensive unit testing. Although functional I still see this more as a POC that this approach can work. Next steps: - Implement `sug` request. - Rework/extend the protocol to allow better client/server communication. Ideally we will need push events, diagnostics should be restructored to allow per file notifications, etc. - implement v3 test suite. - better logging * Add tests for v3 and implement ideSug * Remove typeInstCache/procInstCache cleanup * Add ideChkFile command * Avoid contains call when adding symbol info * Remove log * Remove segfaults
* Refactor and doc package handling, module name mangling (#19821)quantimnot2022-05-301-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor and doc package handling, module name mangling * Consolidate, de-duplicate and extend package handling * Alter how duplicate module names of a package are handled * Alter how module names are mangled * Fix crash when another package is named 'stdlib' (test case added) * Doc what defines a package in the manual Modules with duplicate names within a package used to be given 'fake' packages to resolve conflicts. That prevented the ability to discern if a module belonged to the current project package or a foreign package. They now have the proper package owner and the names are mangled in a consistent manner to prevent codegen clashes. All module names are now mangled the same. Stdlib was treated special before, but now it is same as any other package. This fixes a crash when a foreign package is named 'stdlib'. Module mangling is altered for both file paths and symbols used by the backends. Removed an unused module name to package mapping that may have been intended for IC. The mapping was removed because it wasn't being used and was complicating the issue of package modules with duplicate names not having the proper package owner assigned. * Fix some tests * Refactor `packagehandling` * Remove `packagehandling.withPackageName` and its uses * Move module path mangling from `packagehandling` to `modulepaths` * Move `options.toRodFile` to `ic` to break import cycle * Changed import style to match preferred style Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* move assertions out of system (#19599)flywind2022-03-231-0/+3
|
* Use openarray of bytes in md5 (#19307)hlaaftana2022-01-151-1/+1
| | | | | | | | | | * Use openarray of bytes in md5 * fix CI * cleanup * use noSideEffect for bootstrapping * fix CI again * actually fix CI by checking if it works * this is getting ridiculous * put old md5 version in compiler, remove vmop
* improvements to hint:processing: show import stack, distinguish nims, show ↵Timothee Cour2021-06-301-0/+12
| | | | | | | | includes etc (#18372) * improvements to hint:processing * fix tests; do not show hintProcessing for nimscript unless given -d:nimHintProcessingNims * fix trunner and avoid need for -d:nimHintProcessingNims * fix some tests
* ORC: improvements (#17993)Andreas Rumpf2021-05-121-1/+1
| | | | * ORC: improvements * ORC: fix .acyclic annotation for ref objects
* CIs: attempt to use csources_v1 (#16282)Andreas Rumpf2021-04-211-1/+1
| | | | | | | | * CIs: attempt to use csources_v1 * also updated the BSDs * also updated azure pipelines * std modules should not itself use the 'std/' import dir... * compiler has to be careful with std/ for v1 booting
* `import foo {.all.}` reboot (#17706)Timothee Cour2021-04-161-23/+41
|
* IC: added converter test case (#17688)Andreas Rumpf2021-04-091-0/+4
| | | | | * IC: added converter test case * IC: make converter example work
* makes DrNim compile again (#17584)Andreas Rumpf2021-03-301-1/+2
|
* added a 'koch ic' command for easier adhoc testing of IC (#17508)Andreas Rumpf2021-03-261-0/+16
| | | | | | * added a 'koch ic' command for easier adhoc testing of IC * IC: progress * IC: enable generics test * make tests green
* IC: backend: remember produced type information (#17440)Andreas Rumpf2021-03-231-4/+25
|
* IC: green tests (#17311)Andreas Rumpf2021-03-191-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * IC: renamed to_packed_ast module to ic module * IC: don't store the --forceBuild flag, makes it easier to test * IC: enable hello world test * Codegen: refactorings for IC; changed the name mangling algorithm * fixed the HCR regressions * life is too short for HCR * tconvexhull is now allowed to use deepCopy * IC exposed a stdlib bug, required a refactoring * codegen: code cleanups * IC: even if a module is outdated, its dependencies might come from disk * IC: progress * IC: better name mangling, module IDs are not stable * IC: another refactoring helping with --ic:on --gc:arc * disable arraymancer on Windows for the time being * disable arraymancer altogether * IC: make basic test work with 'nim cpp' * IC: progress on --ic:on --gc:arc * wip; name mangling for type info
* IC: compilerprocs are handled correctly (#17265)Andreas Rumpf2021-03-091-9/+22
| | | | | | | * IC: compilerprocs are handled correctly * IC: special logic for .exportC'ed procs * IC: 'hello world' compiles for the first round (2nd round fails) * IC: hello world seems to work
* IC: bugfixes (WIP) (#16836)Andreas Rumpf2021-02-021-12/+23
| | | | | | | | * minor improvements * IC: added the required logic for compilerProcs * LazySym ftw * we need this testing logic * reimplement the old way we use for module package creation * fixes a regression; don't pick module names if you can avoid it
* IC: final implementation steps (#16801)Andreas Rumpf2021-01-251-71/+111
| | | | | | | | * removed dead code * we need even more laziness for the generic caches * make it bootstrap on older Nims * wrote more deserialization code * IC: replay required methods information
* IC: next steps (#16729)Andreas Rumpf2021-01-231-0/+90
| | | | | | | | | | | * IC: dead code elimination pass * preparations for a different codegen strategy * added documentation to the newly written code * IC: backend code * IC: backend adjustments * optimized the compiler a bit * IC: yet another massive refactoring * fixes regressions * cleanups
* IC: next steps (#16705)Andreas Rumpf2021-01-141-7/+5
| | | | | | | | | | | * code cleanups * refactorings for IC * more refactorings for IC * IC: attach the 'nil' type to its module * IC: refactorings and improvements * IC: progress * IC: more serialization fixes * IC: embarrassing omission * code cleanups
* IC: next steps (#16632)Andreas Rumpf2021-01-121-6/+13
| | | | | | | | | | | | | * removed dead code * beginnings of a rodfile reader * IC: record global VM state changes and pragma state changes * IC: replay pragmas and VM state changes * implemented rod load file simuation for easier, extensive testing * critical bugfix * IC: stress test logic; should also help with recursive module dependencies; WIP * IC: loading from .rod files begins to work reliably * removed ugly hacks * yet another silly mistake
* IC: next steps (#16550)Andreas Rumpf2021-01-071-19/+85
| | | | | | | | | | | | | | | | | | * cleanups * ast.nim: cleanups * IC: no more sym.tab field, stored externally in the module graph * nimble compiles again * rodfiles: store bitwidth of integers and the endianness in the cookie because we serialize 'int' directly * rodfiles: added compilerproc and export sections * rodfiles: added all the missing sections * rodfiles: track the missing information * IC: architecture for lazy loading of proc bodies * make tests green again * completed the lazy loading of proc bodies * symbol lookup integration, part 1 * symbol lookup integration, part 2 * symbol lookup integration, part 3 * make tcompilerapi work again * rodfiles: fixed config change handling
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-021-8/+4
| | | | | | | | | | | | | | | | | | | * reworked ID handling * the packed AST now has its own ID mechanism * basic serialization code works * extract rodfiles to its own module * rodfiles: store and compare configs * rodfiles: store dependencies * store config at the end * precise dependency tracking * dependency tracking for rodfiles * completed loading of PSym, PType, etc * removed dead code * bugfix: do not realloc seqs when taking addr into an element * make IC opt-in for now * makes tcompilerapi green again * final cleanups Co-authored-by: Andy Davidoff <github@andy.disruptek.com>
* misc cleanups (#16383)Timothee Cour2020-12-181-1/+1
|
* refactorings to prepare the compiler for IC (#15935)Andreas Rumpf2020-12-171-9/+26
| | | | | | | | | | | | | | * added ic specific Nim code; WIP * make the symbol import mechanism lazy; WIP * ensure that modules can be imported multiple times * ambiguity checking * handle converters and TR macros properly * make 'enum' test category green again * special logic for semi-pure enums * makes nimsuggest tests green again * fixes nimdata * makes nimpy green again * makes more important packages work
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-251-2/+5
| | | | | | | | | | | | | | | | | * refactoring: idents don't need inheritance * refactoring: adding an IdGenerator (part 1) * refactoring: adding an IdGenerator (part 2) * refactoring: adding an IdGenerator (part 3) * refactoring: adding an IdGenerator (part 4) * refactoring: adding an IdGenerator (part 5) * refactoring: adding an IdGenerator (part 5) * IdGenerator must be a ref type; hello world works again * make bootstrapping work again * progress: add back the 'exactReplica' ideas * added back the missing exactReplica hacks * make tcompilerapi work again * make important packages green * attempt to fix the build for 32 bit machines (probably need a better solution here)
* drnim: tiny progress (#13882)Andreas Rumpf2020-04-151-3/+1
| | | | | | | | | | | * drnim: tiny progress * refactoring complete * drnim: prove .ensures annotations * Moved code around to avoid code duplication * drnim: first implementation of the 'old' property * drnim: be precise about the assignment statement * first implementation of --assumeUnique * progress on forall/exists handling
* DrNim (Nim compiler with Z3 integration) (#13743)Andreas Rumpf2020-03-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | * code cleanups and feature additions * added basic test and koch/CI integration * make it build on Unix * DrNim: now buildable on Unix, only takes 10 minutes, enjoy * added basic documentation for DrNim which can also be seen as the RFC we're following * drnim: change the build setup so that drnim.exe ends up in bin/ * makes simple floating point ranges work * added basic float range check * drnim: teach Z3 about Nim's range types plus code refactoring * drnim: make unsigned numbers work * added and fixed index checking under setLen * first implementation of .ensures, .invariant and .assume (.requires still missing and so is proc type compatibility checking * drnim: .requires checking implemented * drnim: implemented .ensures properly * more impressive test involving min() * drnim: check for proc type compatibility and base method compatibility wrt .requires and .ensures * testament: support for 'pattern <directory> * koch: uses new <directory> feature of testament * drnim: added tiny musings about 'old' * Make testament work with old SSL versions * koch: add support for 'koch drnim -d:release' * drnim: preparations for the param.old notation
* rename sfAlwaysReturn to sfNeverRaisesAraq2020-03-161-1/+1
|
* catchable defects (#13626)Andreas Rumpf2020-03-121-0/+1
| | | | | | | | | | * allow defects to be caught even for --exceptions:goto (WIP) * implemented the new --panics:on|off switch; refs https://github.com/nim-lang/RFCs/issues/180 * new implementation for integer overflow checking * produce a warning if a user-defined exception type inherits from Exception directly * applied Timothee's suggestions; improved the documentation and replace the term 'checked runtime check' by 'panic' * fixes #13627 * don't inherit from Exception directly
* make case-object transitions explicit, make unknownLineInfo a const, replace ↵Jasper Jenkins2020-01-171-1/+1
| | | | a few magic numbers with consts (#13170)
* Fix spellings (#12277) [backport]Federico Ceratto2019-09-271-2/+2
|
* Make name mangling reversable unambiguously (#11939) [bugfix]Clyybber2019-08-141-1/+1
|
* styleCheck: make the compiler and large parts of the stdlib compatible with ↵Araq2019-07-101-1/+1
| | | | --styleCheck:error
* Fix destructor injections for global variables (#11230)Clyybber2019-05-131-0/+1
| | | | | | | | * attach global destructors at end of mainModule * Add testcase * Minor cleanup * Inject topLevelVar temporaries' destructors early * Fix megatest
* Compiler plugin for implementing incremental computation in user space (#10819)cooldome2019-04-111-1/+51
| | | | | | | | | | This plugin provides essential building block for implementing incremental computations in your programs. The idea behind incremental computations is that if you do the same calculation multiple times but with slightly different inputs you don't have to recompute everything from scratch. Also you don't want to adopt special algorithms either, you would like to write your code in standard from scratch manner and get incrementality for free when it is possible. The plugin computes the digest of the proc bodies, recursively hashing all called procs as well . Such digest with the digest of the argument values gives a good "name" for the result. Terminology loosely follows paper "Incremental Computation with Names" link below. It works well if you have no side effects in your computations. If you have global state in your computations then you will need problem specific workarounds to represent global state in set of "names" . SideEffect tracking in Nim also useful in this topic. Classical examples: Dashboard with ticking data. New data arrives non stop and you would like to update the dashboard recomputing only changed outputs. Excel spreadsheet where user changes one cell and you would like to recompute all cells that are affected by the change, but do not want to recompute every cell in the spreadsheet.
* newruntime: progressAraq2019-04-011-1/+3
|
* Initial version of the hot-code reloading support for native targets (#10729)zah2019-02-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * squashed work by Zahary * squashing a ton of useful history... otherwise rebasing on top of upstream Nim after commit 82c009a2cbc5d07ab9a847f1c58228a20efaf219 would be impossible. * Code review changes; Working test suite (without code reloading enabled) * - documentation - implemented the HCR test - almost works... - fix the issue on Unix where for executable targets the source file for the main module of a project in nimcache was being overwritten with the binary itself (and thus the actual source code was lost) - fixing embedded paths to shared objects on unix (the "lib" prefix was being prepended to the entire path instead of just the filename) - other fixes - removing unnecessary includes since that file is already included in chcks.nim which is in turn included in system.nim (and previously was getting imported in chcks.nim but then system.nim improts something... and that breaks HCR (perhaps it could be fixed but it would be nice not to import anything in system)) * fix for clang & C++ - explicitly casting a function pointer to void* more stable mangling of parameter names when HCR is on the length of the static arrays in the DatInit functions is now part of the name of the variables, so when they get resized they get also recreated more stable mangling for inline functions - no longer depends on the module which first used them work on the new complicated HCR test - turned surprisingly complex - WIP test now successfully passes even when re-running `koch test` (previously when the nimcache wasn't cold that lead to errors) better documentation calling setStackBottomWith for PreMain passes over the HcrInit/DatInit/Init calls of all modules are now in the proper order (first all of one type, then all of the next). Also typeinfo globals are registered (created) in a single pass before the DatInit pass (because of the way generic instantiations are handled) Fix the test suite execution on macOs fix for being able to query the program arguments when using HCR on posix! other fixes * Bugfix: Fix a compilation error in C++ mode when a function pointer is converted to a raw pointer * basic documentation for the new hot code reloading semantics * Add change log entry * Don't re-execute the top-level statements while reloading JS code * fix a number of tests broken in a recent bugfix * Review changes * Added {.executeOnReload.} pragma that indicates top-level statements that should be executed on each reload. To make this work, I've modified the way the `if (hcr_init_) {...}` guards are produced in the init code. This still needs more work as the new guards seem to be inserted within the previously generated guards. This change also removes the need for `lastRegistedGlobal` in nimhcr. * Implemented the `signatureHash` magic and the `hasModuleChanged` API depending on it (the actual logic is not imlemented yet). * Add the "hcr" prefix to all HCR-related symbols in the system module. Added a new `hotcodereloading` module exporting the high-level API to the user. Besides being more hygienic, this was also required in order to make it possible to use macros in the high-level API. Without the split, `system` would have to import `macros`, which was going to produce the well-known init problems. * Attempted to solve the "GC markers problem". Crashes were expected with the previous code, because the GC markers were compiled as normal procs are registered in the GC. When their module is unloaded, dangling pointers will remain in the GC tables. To solve this issue, I don't register any GC markers when HCR is on, but I add them to the HCR globals metadata and I use a single marker registed in nimhcr during the initialization of the system module that will be responsible for marking all globals. * fix a compilation error * - implemented the hasModuleChanged functionality - tuples can be returned and broken into different vars in global scope - added comments for the closnig scopes of the if statements in the init proc - the new executeOnReload pragma works now! - other fixes * finally! fixing this hack in a proper way - declaring the destructor out of line (out of the class body) - we no longer need to forward-declare popCurrentExceptionEx * Force full module parsing This is a temporary hack that breaks some tests. I'll investigate later how these can be fixed. * tuples are now properly handled when global! * these comments mess up the codegen in debug mode when $n is not actually a new line (or something like that) - these labels are intended only for GOTO labels anyway... * "solved" the issue with the .pdb locks on windows when a binary is being debugged and hot code reloading is used at the same time * fixes after rebasing... * small fixes for the test * better handling of globals! no more compiler crashes for locals with the global pragma, also simplified code around loops in global scope which have local vars (actually globals) * we can now use the global pragma even for ... globals! * the right output * lets try those boehm GC tests * after the test is ran it will be at its starting state - no git modifications * clarification in the docs * removed unnecessary line directives for forward declarations of functions - they were causing trouble with hot code reloading when no semantic change propagates to the main module but a line directive got changed and thus the main module had to be recompiled since the .c code had changed * fixed bug! was inserting duplicate keys into the table and later was removing only 1 copy of all the duplicates (after a few reloads) * no longer breaking into DatInit code when not supposed to * fixes after rebasing * yet more fixes after rebasing * Update jssys.nim * Rework the HCR path-handling logic After reviewing the code more carefully, I've noticed that the old logic will be broken when the user overrides the '--out:f' compiler option. Besides fixing this issues, I took the opportunity to implement the missing '--outdir:d' option. Other changes: * ./koch test won't overwrite any HCR and RTL builds located in nim/lib * HCR and RTL are compiled with --threads:on by default * Clean up the globals registration logic * Handle non-flattened top-level stmtlists in JS as well * The HCR is not supported with the Boehm GC yet Also fixes some typos and the expected output of the HCR integration test * The GC marker procs are now properly used as trampolines * Fix the HCR integration test in release builds * Fix ./koch tools * this forward declaration doesn't seem to be necessary, and in fact breaks HCR because a 2nd function pointer is emitted for this externed/rtl func * the forward declaration I removed in the last commit was actually necessary * Attempt to make all tests green * Fix tgenscript * BAT file for running the HCR integration test on Windows [skip ci] * Fix the docgen tests * A final fix for Travis (hopefully)
* compiler refactoring: TSymSeq is gone for goodAraq2018-12-111-1/+1
|
* added first version of a nimfind tool for the poor souls that don't have a ↵Andreas Rumpf2018-11-141-0/+29
| | | | good nimsuggest integretation
* Make the registered passes local to the ModuleGraph (#9259)LemonBoy2018-10-091-0/+13
| | | Closes #9068
* deprecate the .this pragmaAraq2018-08-091-28/+26
|
* completed VM support for incremental compilationsAndreas Rumpf2018-06-041-1/+7
|
* incremental compilation: implemented basic replay logicAndreas Rumpf2018-06-021-0/+5
|
* document how the incremental compilation scheme could workAndreas Rumpf2018-06-011-1/+1
|
* refactoring: move DB model to incremental.nimAndreas Rumpf2018-05-301-4/+7
|
* vm now free of global variablesAndreas Rumpf2018-05-281-0/+2
|
* refactoring: remove idents.legacy global variable and pass the IdentCache ↵Andreas Rumpf2018-05-271-7/+6
| | | | around explicitly
* remove more global variables in the Nim compilerAndreas Rumpf2018-05-271-1/+1
|
* remove ast.emptyNode global; cleanup configuration.nimAraq2018-05-161-0/+2
|
* options.nim: no global variables anymoreAndreas Rumpf2018-05-131-1/+1
|
* sem pass compiles againAndreas Rumpf2018-05-121-1/+8
|


                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           



                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             


                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 






                                                                                                                                                                                                                                                                                                                                                                                                                     

                                                                                                                                                                                                                                                                                                                                                                                                         







                                                                                                                                                                                      
                                           



                                                                                                                                
                                                                                                                             

                                                                                                                                                      
                                           



                                                                                                                                               
                                                                                                                             















































































                                                                                                                                                                                                                                                                                                              


       
                                     
<!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 - 046check_type_by_name.cc</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="number_lines,use_css,pre_wrap,no_foldcolumn,expand_tabs,line_ids,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #aaaaaa; background-color: #080808; }
body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: #080808; }
.subxS2Comment a { color:inherit; }
.subxS1Comment a { color:inherit; }
.subxComment a { color:inherit; }
.subxH2Comment a { color:inherit; }
.subxH1Comment a { color:inherit; }
* { font-size:12pt; font-size: 1em; }
.LineNr { color:#444444; }
.traceAbsent { color: #c00000; }
.Constant { color:#00a0a0; }
.muRecipe { color: #ff8700; }
.Delimiter { color:#800080; }
.Special { color:#c00000; }
.Identifier { color:#c0a020; }
.Normal { color: #aaaaaa; background-color: #080808; padding-bottom: 1px; }
.Comment { color: #8080ff; }
.cSpecial { color: #008000; }
.traceContains { color: #008000; }
-->
</style>

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

/* function to open any folds containing a jumped-to line before jumping to it */
function JumpToLine()
{
  var lineNum;
  lineNum = window.location.hash;
  lineNum = lineNum.substr(1); /* strip off '#' */

  if (lineNum.indexOf('L') == -1) {
    lineNum = 'L'+lineNum;
  }
  lineElem = document.getElementById(lineNum);
  /* Always jump to new location even if the line was hidden inside a fold, or
   * we corrected the raw number to a line ID.
   */
  if (lineElem) {
    lineElem.scrollIntoView(true);
  }
  return true;
}
if ('onhashchange' in window) {
  window.onhashchange = JumpToLine;
}

-->
</script>
</head>
<body onload='JumpToLine();'>
<a href='https://github.com/akkartik/mu/blob/master/046check_type_by_name.cc'>https://github.com/akkartik/mu/blob/master/046check_type_by_name.cc</a>
<pre id='vimCodeElement'>
<span id="L1" class="LineNr">  1 </span><span class="Comment">//: Some simple sanity checks for types, and also attempts to guess them where</span>
<span id="L2" class="LineNr">  2 </span><span class="Comment">//: they aren't provided.</span>
<span id="L3" class="LineNr">  3 </span><span class="Comment">//:</span>
<span id="L4" class="LineNr">  4 </span><span class="Comment">//: You still have to provide the full type the first time you mention a</span>
<span id="L5" class="LineNr">  5 </span><span class="Comment">//: variable in a recipe. You have to explicitly name :offset and :variant</span>
<span id="L6" class="LineNr">  6 </span><span class="Comment">//: every single time. You can't use the same name with multiple types in a</span>
<span id="L7" class="LineNr">  7 </span><span class="Comment">//: single recipe.</span>
<span id="L8" class="LineNr">  8 </span>
<span id="L9" class="LineNr">  9 </span><span class="Delimiter">:(scenario transform_fails_on_reusing_name_with_different_type)</span>
<span id="L10" class="LineNr"> 10 </span><span class="Special">% Hide_errors = true;</span>
<span id="L11" class="LineNr"> 11 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L12" class="LineNr"> 12 </span>  <span class="Normal">x</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
<span id="L13" class="LineNr"> 13 </span>  <span class="Normal">x</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
<span id="L14" class="LineNr"> 14 </span>]
<span id="L15" class="LineNr"> 15 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: 'x' used with multiple types</span>
<span id="L16" class="LineNr"> 16 </span>
<span id="L17" class="LineNr"> 17 </span><span class="Comment">//: we need surrounding-space info for type-checking variables in other spaces</span>
<span id="L18" class="LineNr"> 18 </span><span class="Delimiter">:(after &quot;Transform.push_back(collect_surrounding_spaces)&quot;)</span>
<span id="L19" class="LineNr"> 19 </span><span class="Special">Transform</span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='046check_type_by_name.cc.html#L35'>check_or_set_types_by_name</a><span class="Delimiter">);</span>  <span class="Comment">// idempotent</span>
<span id="L20" class="LineNr"> 20 </span>
<span id="L21" class="LineNr"> 21 </span><span class="Comment">// Keep the name-&gt;type mapping for all recipes around for the entire</span>
<span id="L22" class="LineNr"> 22 </span><span class="Comment">// transformation phase.</span>
<span id="L23" class="LineNr"> 23 </span><span class="Delimiter">:(before &quot;End Globals&quot;)</span>
<span id="L24" class="LineNr"> 24 </span>map&lt;recipe_ordinal<span class="Delimiter">,</span> set&lt;reagent<span class="Delimiter">,</span> name_lt&gt; &gt; <span class="Special">Types_by_space</span><span class="Delimiter">;</span>  <span class="Comment">// internal to transform; no need to snapshot</span>
<span id="L25" class="LineNr"> 25 </span><span class="Delimiter">:(before &quot;End Reset&quot;)</span>
<span id="L26" class="LineNr"> 26 </span><span class="Special">Types_by_space</span><span class="Delimiter">.</span><a href='050scenario.cc.html#L60'>clear</a><span class="Delimiter">();</span>
<span id="L27" class="LineNr"> 27 </span><span class="Delimiter">:(before &quot;End transform_all&quot;)</span>
<span id="L28" class="LineNr"> 28 </span><span class="Special">Types_by_space</span><span class="Delimiter">.</span><a href='050scenario.cc.html#L60'>clear</a><span class="Delimiter">();</span>
<span id="L29" class="LineNr"> 29 </span><span class="Delimiter">:(before &quot;End Types&quot;)</span>
<span id="L30" class="LineNr"> 30 </span><span class="Normal">struct</span> <a href='046check_type_by_name.cc.html#L30'>name_lt</a> <span class="Delimiter">{</span>
<span id="L31" class="LineNr"> 31 </span>  <span class="Normal">bool</span> <span class="Normal">operator</span><span class="Delimiter">()(</span><span class="Normal">const</span> reagent&amp; a<span class="Delimiter">,</span> <span class="Normal">const</span> reagent&amp; b<span class="Delimiter">)</span> <span class="Normal">const</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> a<span class="Delimiter">.</span>name &lt; b<span class="Delimiter">.</span>name<span class="Delimiter">;</span> <span class="Delimiter">}</span>
<span id="L32" class="LineNr"> 32 </span><span class="Delimiter">};</span>
<span id="L33" class="LineNr"> 33 </span>
<span id="L34" class="LineNr"> 34 </span><span class="Delimiter">:(code)</span>
<span id="L35" class="LineNr"> 35 </span><span class="Normal">void</span> <a href='046check_type_by_name.cc.html#L35'>check_or_set_types_by_name</a><span class="Delimiter">(</span><span class="Normal">const</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L36" class="LineNr"> 36 </span>  recipe&amp; caller = get<span class="Delimiter">(</span><span class="Special">Recipe</span><span class="Delimiter">,</span> r<span class="Delimiter">);</span>
<span id="L37" class="LineNr"> 37 </span>  <a href='003trace.cc.html#L189'>trace</a><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;--- deduce types for <a href='010vm.cc.html#L19'>recipe</a> &quot;</span> &lt;&lt; caller<span class="Delimiter">.</span>name &lt;&lt; <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span>
<span id="L38" class="LineNr"> 38 </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; <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span>  ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L39" class="LineNr"> 39 </span>    instruction&amp; inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
<span id="L40" class="LineNr"> 40 </span>    <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> in = <span class="Constant">0</span><span class="Delimiter">;</span>  in &lt; <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span>  ++in<span class="Delimiter">)</span>
<span id="L41" class="LineNr"> 41 </span>      <a href='046check_type_by_name.cc.html#L47'>check_or_set_type</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> caller<span class="Delimiter">);</span>
<span id="L42" class="LineNr"> 42 </span>    <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> out = <span class="Constant">0</span><span class="Delimiter">;</span>  out &lt; <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span>  ++out<span class="Delimiter">)</span>
<span id="L43" class="LineNr"> 43 </span>      <a href='046check_type_by_name.cc.html#L47'>check_or_set_type</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> caller<span class="Delimiter">);</span>
<span id="L44" class="LineNr"> 44 </span>  <span class="Delimiter">}</span>
<span id="L45" class="LineNr"> 45 </span><span class="Delimiter">}</span>
<span id="L46" class="LineNr"> 46 </span>
<span id="L47" class="LineNr"> 47 </span><span class="Normal">void</span> <a href='046check_type_by_name.cc.html#L47'>check_or_set_type</a><span class="Delimiter">(</span>reagent&amp; curr<span class="Delimiter">,</span> <span class="Normal">const</span> recipe&amp; caller<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L48" class="LineNr"> 48 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L49" class="LineNr"> 49 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span>  <span class="Comment">// no type-checking for raw locations</span>
<span id="L50" class="LineNr"> 50 </span>  set&lt;reagent<span class="Delimiter">,</span> name_lt&gt;&amp; known_types = <span class="Special">Types_by_space</span>[owning_recipe<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> caller<span class="Delimiter">.</span>ordinal<span class="Delimiter">)</span>]<span class="Delimiter">;</span>
<span id="L51" class="LineNr"> 51 </span>  <a href='046check_type_by_name.cc.html#L55'>deduce_missing_type</a><span class="Delimiter">(</span>known_types<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> caller<span class="Delimiter">);</span>
<span id="L52" class="LineNr"> 52 </span>  <a href='046check_type_by_name.cc.html#L76'>check_type</a><span class="Delimiter">(</span>known_types<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> caller<span class="Delimiter">);</span>
<span id="L53" class="LineNr"> 53 </span><span class="Delimiter">}</span>
<span id="L54" class="LineNr"> 54 </span>
<span id="L55" class="LineNr"> 55 </span><span class="Normal">void</span> <a href='046check_type_by_name.cc.html#L55'>deduce_missing_type</a><span class="Delimiter">(</span>set&lt;reagent<span class="Delimiter">,</span> name_lt&gt;&amp; known_types<span class="Delimiter">,</span> reagent&amp; x<span class="Delimiter">,</span> <span class="Normal">const</span> recipe&amp; caller<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L56" class="LineNr"> 56 </span>  <span class="Comment">// Deduce Missing Type(x, caller)</span>
<span id="L57" class="LineNr"> 57 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L58" class="LineNr"> 58 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span><a href='041jump_target.cc.html#L11'>is_jump_target</a><span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span>
<span id="L59" class="LineNr"> 59 </span>    x<span class="Delimiter">.</span>type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span><span class="Constant">&quot;label&quot;</span><span class="Delimiter">);</span>
<span id="L60" class="LineNr"> 60 </span>    <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L61" class="LineNr"> 61 </span>  <span class="Delimiter">}</span>
<span id="L62" class="LineNr"> 62 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>known_types<span class="Delimiter">.</span>find<span class="Delimiter">(</span>x<span class="Delimiter">)</span> == known_types<span class="Delimiter">.</span><a href='003trace.cc.html#L225'>end</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L63" class="LineNr"> 63 </span>  <span class="Normal">const</span> reagent&amp; exemplar = *known_types<span class="Delimiter">.</span>find<span class="Delimiter">(</span>x<span class="Delimiter">);</span>
<span id="L64" class="LineNr"> 64 </span>  x<span class="Delimiter">.</span>type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span>*exemplar<span class="Delimiter">.</span>type<span class="Delimiter">);</span>
<span id="L65" class="LineNr"> 65 </span>  <a href='003trace.cc.html#L189'>trace</a><span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; x<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot; &lt;= &quot;</span> &lt;&lt; names_to_string<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> &lt;&lt; <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span>
<span id="L66" class="LineNr"> 66 </span>  <span class="Comment">// spaces are special; their type includes their /names property</span>
<span id="L67" class="LineNr"> 67 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span><a href='043space.cc.html#L127'>is_mu_space</a><span class="Delimiter">(</span>x<span class="Delimiter">)</span> &amp;&amp; !has_property<span class="Delimiter">(</span>x<span class="Delimiter">,</span> <span class="Constant">&quot;names&quot;</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
<span id="L68" class="LineNr"> 68 </span>    <span class="Normal">if</span> <span class="Delimiter">(</span>!has_property<span class="Delimiter">(</span>exemplar<span class="Delimiter">,</span> <span class="Constant">&quot;names&quot;</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
<span id="L69" class="LineNr"> 69 </span>      <a href='003trace.cc.html#L196'>raise</a> &lt;&lt; <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;missing /names property for space variable '&quot;</span> &lt;&lt; exemplar<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;'\n&quot;</span> &lt;&lt; <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span>
<span id="L70" class="LineNr"> 70 </span>      <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L71" class="LineNr"> 71 </span>    <span class="Delimiter">}</span>
<span id="L72" class="LineNr"> 72 </span>    x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair&lt;string<span class="Delimiter">,</span> string_tree*&gt;<span class="Delimiter">(</span><span class="Constant">&quot;names&quot;</span><span class="Delimiter">,</span> <span class="Normal">new</span> string_tree<span class="Delimiter">(</span>*property<span class="Delimiter">(</span>exemplar<span class="Delimiter">,</span> <span class="Constant">&quot;names&quot;</span><span class="Delimiter">))));</span>
<span id="L73" class="LineNr"> 73 </span>  <span class="Delimiter">}</span>
<span id="L74" class="LineNr"> 74 </span><span class="Delimiter">}</span>
<span id="L75" class="LineNr"> 75 </span>
<span id="L76" class="LineNr"> 76 </span><span class="Normal">void</span> <a href='046check_type_by_name.cc.html#L76'>check_type</a><span class="Delimiter">(</span>set&lt;reagent<span class="Delimiter">,</span> name_lt&gt;&amp; known_types<span class="Delimiter">,</span> <span class="Normal">const</span> reagent&amp; x<span class="Delimiter">,</span> <span class="Normal">const</span> recipe&amp; caller<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L77" class="LineNr"> 77 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L78" class="LineNr"> 78 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span>  <span class="Comment">// might get filled in by other logic later</span>
<span id="L79" class="LineNr"> 79 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span><a href='041jump_target.cc.html#L11'>is_jump_target</a><span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span>
<span id="L80" class="LineNr"> 80 </span>    <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>atom || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>name != <span class="Constant">&quot;label&quot;</span><span class="Delimiter">)</span>
<span id="L81" class="LineNr"> 81 </span>      <a href='003trace.cc.html#L196'>raise</a> &lt;&lt; <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;non-label '&quot;</span> &lt;&lt; x<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;' must begin with a letter\n&quot;</span> &lt;&lt; <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span>
<span id="L82" class="LineNr"> 82 </span>    <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L83" class="LineNr"> 83 </span>  <span class="Delimiter">}</span>
<span id="L84" class="LineNr"> 84 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>known_types<span class="Delimiter">.</span>find<span class="Delimiter">(</span>x<span class="Delimiter">)</span> == known_types<span class="Delimiter">.</span><a href='003trace.cc.html#L225'>end</a><span class="Delimiter">())</span> <span class="Delimiter">{</span>
<span id="L85" class="LineNr"> 85 </span>    <a href='003trace.cc.html#L189'>trace</a><span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; x<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot; =&gt; &quot;</span> &lt;&lt; names_to_string<span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> &lt;&lt; <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span>
<span id="L86" class="LineNr"> 86 </span>    known_types<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>x<span class="Delimiter">);</span>
<span id="L87" class="LineNr"> 87 </span>  <span class="Delimiter">}</span>
<span id="L88" class="LineNr"> 88 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>!types_strictly_match<span class="Delimiter">(</span>known_types<span class="Delimiter">.</span>find<span class="Delimiter">(</span>x<span class="Delimiter">)-&gt;</span>type<span class="Delimiter">,</span> x<span class="Delimiter">.</span>type<span class="Delimiter">))</span> <span class="Delimiter">{</span>
<span id="L89" class="LineNr"> 89 </span>    <a href='003trace.cc.html#L196'>raise</a> &lt;&lt; <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'&quot;</span> &lt;&lt; x<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;' used with multiple types\n&quot;</span> &lt;&lt; <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span>
<span id="L90" class="LineNr"> 90 </span>    <a href='003trace.cc.html#L196'>raise</a> &lt;&lt; <span class="Constant">&quot;  &quot;</span> &lt;&lt; <a href='028call_return.cc.html#L163'>to_string</a><span class="Delimiter">(</span>known_types<span class="Delimiter">.</span>find<span class="Delimiter">(</span>x<span class="Delimiter">)-&gt;</span>type<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot; vs &quot;</span> &lt;&lt; <a href='028call_return.cc.html#L163'>to_string</a><span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">)</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span>
<span id="L91" class="LineNr"> 91 </span>    <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L92" class="LineNr"> 92 </span>  <span class="Delimiter">}</span>
<span id="L93" class="LineNr"> 93 </span>  <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_array<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Delimiter">{</span>
<span id="L94" class="LineNr"> 94 </span>    <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L95" class="LineNr"> 95 </span>      <a href='003trace.cc.html#L196'>raise</a> &lt;&lt; <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'&quot;</span> &lt;&lt; x<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;: can't be just an array. What is it an array of?\n&quot;</span> &lt;&lt; <a href='003trace.cc.html#L225'>end</a><span class="Delimiter">();</span>
<span id="L96" class="LineNr"> 96 </span>      <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L97" class="LineNr"> 97 </span>    <span class="Delimiter">}</span>
<span id="L98" class="LineNr"> 98 </span>    <span class="Normal">if</span> <span class="Delimiter">(</span>!x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L99" class="LineNr"> 99 </span>      <a href='003trace.cc.html#L196'>raise</a> &lt;&lt; caller<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot; can't determine the size of array variable '&quot;</span> &lt;&lt; x<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;'. Either allocate it separately and make the type of '&quot;</span> &lt;&lt; x<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;' an address, or specify the length of the array in the type of '&quot;</span> &lt;&lt; x<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;'.\n&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
<span id="L100" class="LineNr">100 </span>      <span class="Identifier">return</span><span class="Delimiter">;</span>
<span id="L101" class="LineNr">101 </span>    <span class="Delimiter">}</span>
<span id="L102" class="LineNr">102 </span>  <span class="Delimiter">}</span>
<span id="L103" class="LineNr">103 </span><span class="Delimiter">}</span>
<span id="L104" class="LineNr">104 </span>
<span id="L105" class="LineNr">105 </span><a href='010vm.cc.html#L14'>recipe_ordinal</a> <a href='046check_type_by_name.cc.html#L105'>owning_recipe</a><span class="Delimiter">(</span><span class="Normal">const</span> reagent&amp; x<span class="Delimiter">,</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L106" class="LineNr">106 </span>  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> s = <a href='044space_surround.cc.html#L56'>space_index</a><span class="Delimiter">(</span>x<span class="Delimiter">);</span> s &gt; <span class="Constant">0</span><span class="Delimiter">;</span> --s<span class="Delimiter">)</span> <span class="Delimiter">{</span>
<span id="L107" class="LineNr">107 </span>    <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span><span class="Special">Surrounding_space</span><span class="Delimiter">,</span> r<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span>  <span class="Comment">// error raised elsewhere</span>
<span id="L108" class="LineNr">108 </span>    r = <span class="Special">Surrounding_space</span>[r]<span class="Delimiter">;</span>
<span id="L109" class="LineNr">109 </span>  <span class="Delimiter">}</span>
<span id="L110" class="LineNr">110 </span>  <span class="Identifier">return</span> r<span class="Delimiter">;</span>
<span id="L111" class="LineNr">111 </span><span class="Delimiter">}</span>
<span id="L112" class="LineNr">112 </span>
<span id="L113" class="LineNr">113 </span><span class="Delimiter">:(scenario transform_fills_in_missing_types)</span>
<span id="L114" class="LineNr">114 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L115" class="LineNr">115 </span>  <span class="Normal">x</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">11</span>
<span id="L116" class="LineNr">116 </span>  <span class="Normal">y</span>:num<span class="Special"> &lt;- </span>add x<span class="Delimiter">,</span> <span class="Constant">1</span>
<span id="L117" class="LineNr">117 </span>]
<span id="L118" class="LineNr">118 </span><span class="Comment"># x is in location 2, y in location 3</span>
<span id="L119" class="LineNr">119 </span><span class="traceContains">+mem: storing 12 in location 3</span>
<span id="L120" class="LineNr">120 </span>
<span id="L121" class="LineNr">121 </span><span class="Delimiter">:(scenario transform_fills_in_missing_types_in_product)</span>
<span id="L122" class="LineNr">122 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L123" class="LineNr">123 </span>  <span class="Normal">x</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">11</span>
<span id="L124" class="LineNr">124 </span>  x<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
<span id="L125" class="LineNr">125 </span>]
<span id="L126" class="LineNr">126 </span><span class="Comment"># x is in location 2</span>
<span id="L127" class="LineNr">127 </span><span class="traceContains">+mem: storing 12 in location 2</span>
<span id="L128" class="LineNr">128 </span>
<span id="L129" class="LineNr">129 </span><span class="Delimiter">:(scenario transform_fills_in_missing_types_in_product_and_ingredient)</span>
<span id="L130" class="LineNr">130 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L131" class="LineNr">131 </span>  <span class="Normal">x</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">11</span>
<span id="L132" class="LineNr">132 </span>  x<span class="Special"> &lt;- </span>add x<span class="Delimiter">,</span> <span class="Constant">1</span>
<span id="L133" class="LineNr">133 </span>]
<span id="L134" class="LineNr">134 </span><span class="Comment"># x is in location 2</span>
<span id="L135" class="LineNr">135 </span><span class="traceContains">+mem: storing 12 in location 2</span>
<span id="L136" class="LineNr">136 </span>
<span id="L137" class="LineNr">137 </span><span class="Delimiter">:(scenario transform_fills_in_missing_label_type)</span>
<span id="L138" class="LineNr">138 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L139" class="LineNr">139 </span>  jump +target
<span id="L140" class="LineNr">140 </span>  <span class="Constant">1</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
<span id="L141" class="LineNr">141 </span>  +target
<span id="L142" class="LineNr">142 </span>]
<span id="L143" class="LineNr">143 </span><span class="traceAbsent">-mem: storing 0 in location 1</span>
<span id="L144" class="LineNr">144 </span>
<span id="L145" class="LineNr">145 </span><span class="Delimiter">:(scenario transform_fails_on_missing_types_in_first_mention)</span>
<span id="L146" class="LineNr">146 </span><span class="Special">% Hide_errors = true;</span>
<span id="L147" class="LineNr">147 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L148" class="LineNr">148 </span>  x<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
<span id="L149" class="LineNr">149 </span>  <span class="Normal">x</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">2</span>
<span id="L150" class="LineNr">150 </span>]
<span id="L151" class="LineNr">151 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: missing type for 'x' in 'x &lt;- copy 1'</span>
<span id="L152" class="LineNr">152 </span>
<span id="L153" class="LineNr">153 </span><span class="Delimiter">:(scenario transform_fails_on_wrong_type_for_label)</span>
<span id="L154" class="LineNr">154 </span><span class="Special">% Hide_errors = true;</span>
<span id="L155" class="LineNr">155 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L156" class="LineNr">156 </span>  +foo:num<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
<span id="L157" class="LineNr">157 </span>]
<span id="L158" class="LineNr">158 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: non-label '+foo' must begin with a letter</span>
<span id="L159" class="LineNr">159 </span>
<span id="L160" class="LineNr">160 </span><span class="Delimiter">:(scenario typo_in_address_type_fails)</span>
<span id="L161" class="LineNr">161 </span><span class="Special">% Hide_errors = true;</span>
<span id="L162" class="LineNr">162 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L163" class="LineNr">163 </span>  <span class="Normal">y</span>:&amp;:charcter<span class="Special"> &lt;- </span><span class="Normal">new</span> <span class="Constant">character:type</span>
<span id="L164" class="LineNr">164 </span>  *y<span class="Special"> &lt;- </span>copy <span class="Constant">67</span>
<span id="L165" class="LineNr">165 </span>]
<span id="L166" class="LineNr">166 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: unknown type charcter in 'y:&amp;:charcter &lt;- new character:type'</span>
<span id="L167" class="LineNr">167 </span>
<span id="L168" class="LineNr">168 </span><span class="Delimiter">:(scenario array_type_without_size_fails)</span>
<span id="L169" class="LineNr">169 </span><span class="Special">% Hide_errors = true;</span>
<span id="L170" class="LineNr">170 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L171" class="LineNr">171 </span>  <span class="Normal">x</span>:@:num<span class="Special"> &lt;- </span>merge <span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">12</span><span class="Delimiter">,</span> <span class="Constant">13</span>
<span id="L172" class="LineNr">172 </span>]
<span id="L173" class="LineNr">173 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a> can't determine the size of array variable 'x'. Either allocate it separately and make the type of 'x' an address, or specify the length of the array in the type of 'x'.</span>
<span id="L174" class="LineNr">174 </span>
<span id="L175" class="LineNr">175 </span><span class="Delimiter">:(scenarios transform)</span>
<span id="L176" class="LineNr">176 </span><span class="Delimiter">:(scenario transform_checks_types_of_identical_reagents_in_multiple_spaces)</span>
<span id="L177" class="LineNr">177 </span><span class="muRecipe">def</span> foo [  <span class="Comment"># dummy</span>
<span id="L178" class="LineNr">178 </span>]
<span id="L179" class="LineNr">179 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L180" class="LineNr">180 </span>  local-scope
<span id="L181" class="LineNr">181 </span>  <span class="Constant">0</span>:space/names:foo<span class="Special"> &lt;- </span>copy<span class="Constant"> null</span>  <span class="Comment"># specify surrounding space</span>
<span id="L182" class="LineNr">182 </span>  <span class="Normal">x</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>copy<span class="Constant"> true</span>
<span id="L183" class="LineNr">183 </span>  <span class="Normal">x</span>:num/space:<span class="Constant">1</span><span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
<span id="L184" class="LineNr">184 </span>  x/space:<span class="Constant">1</span><span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
<span id="L185" class="LineNr">185 </span>]
<span id="L186" class="LineNr">186 </span>$error: <span class="Constant">0</span>
<span id="L187" class="LineNr">187 </span>
<span id="L188" class="LineNr">188 </span><span class="Delimiter">:(scenario transform_handles_empty_reagents)</span>
<span id="L189" class="LineNr">189 </span><span class="Special">% Hide_errors = true;</span>
<span id="L190" class="LineNr">190 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L191" class="LineNr">191 </span>  add *
<span id="L192" class="LineNr">192 </span>]
<span id="L193" class="LineNr">193 </span><span class="traceContains">+error: illegal name '*'</span>
<span id="L194" class="LineNr">194 </span><span class="Comment"># no crash</span>
<span id="L195" class="LineNr">195 </span>
<span id="L196" class="LineNr">196 </span><span class="Delimiter">:(scenario transform_checks_types_in_surrounding_spaces)</span>
<span id="L197" class="LineNr">197 </span><span class="Special">% Hide_errors = true;</span>
<span id="L198" class="LineNr">198 </span><span class="Comment"># 'x' is a bool in foo's space</span>
<span id="L199" class="LineNr">199 </span><span class="muRecipe">def</span> foo [
<span id="L200" class="LineNr">200 </span>  local-scope
<span id="L201" class="LineNr">201 </span>  <span class="Normal">x</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>copy<span class="Constant"> false</span>
<span id="L202" class="LineNr">202 </span>  <span class="Identifier">return</span> <span class="Normal">default</span>-space/names:foo
<span id="L203" class="LineNr">203 </span>]
<span id="L204" class="LineNr">204 </span><span class="Comment"># try to read 'x' as a num in foo's space</span>
<span id="L205" class="LineNr">205 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [
<span id="L206" class="LineNr">206 </span>  local-scope
<span id="L207" class="LineNr">207 </span>  <span class="Constant">0</span>:space/names:foo<span class="Special"> &lt;- </span>foo
<span id="L208" class="LineNr">208 </span>  <span class="Normal">x</span>:num/space:<span class="Constant">1</span><span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
<span id="L209" class="LineNr">209 </span>]
<span id="L210" class="LineNr">210 </span><span class="Normal">error</span>: foo: <span class="Constant">'x'</span> used with multiple types
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->