1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[1366],{69293(e,r,n){n.r(r),n.d(r,{assets:()=>c,contentTitle:()=>d,default:()=>p,frontMatter:()=>o,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"libraries/standard_library/meta/typed_expr","title":"TypedExpr","description":"Resolved, type-checked expressions\u2014retrieve types, access referenced function definitions, and more.","source":"@site/versioned_docs/version-v1.0.0-rc.1/libraries/standard_library/meta/typed_expr.md","sourceDirName":"libraries/standard_library/meta","slug":"/libraries/standard_library/meta/typed_expr","permalink":"/docs/v1.0.0-rc.1/libraries/standard_library/meta/typed_expr","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/versioned_docs/version-v1.0.0-rc.1/libraries/standard_library/meta/typed_expr.md","tags":[],"version":"v1.0.0-rc.1","frontMatter":{"title":"TypedExpr","description":"Resolved, type-checked expressions\u2014retrieve types, access referenced function definitions, and more."},"sidebar":"sidebar","previous":{"title":"TypeDefinition","permalink":"/docs/v1.0.0-rc.1/libraries/standard_library/meta/type_def"},"next":{"title":"UnresolvedType","permalink":"/docs/v1.0.0-rc.1/libraries/standard_library/meta/unresolved_type"}}');var s=n(74848),i=n(28453);const o={title:"TypedExpr",description:"Resolved, type-checked expressions\u2014retrieve types, access referenced function definitions, and more."},d=void 0,c={},a=[{value:"Methods",id:"methods",level:2},{value:"as_function_definition",id:"as_function_definition",level:3},{value:"get_type",id:"get_type",level:3},{value:"location",id:"location",level:3}];function l(e){const r={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",sub:"sub",sup:"sup",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(r.p,{children:[(0,s.jsx)(r.code,{children:"std::meta::typed_expr"})," contains methods on the built-in ",(0,s.jsx)(r.code,{children:"TypedExpr"})," type for resolved and type-checked expressions."]}),"\n",(0,s.jsx)(r.h2,{id:"methods",children:"Methods"}),"\n",(0,s.jsx)(r.h3,{id:"as_function_definition",children:"as_function_definition"}),"\n",(0,s.jsx)(r.pre,{children:(0,s.jsx)(r.code,{className:"language-rust",metastring:'title="as_function_definition" showLineNumbers ',children:"pub comptime fn as_function_definition(self) -> Option<FunctionDefinition> {}\n"})}),"\n",(0,s.jsxs)(r.blockquote,{children:["\n",(0,s.jsx)(r.p,{children:(0,s.jsx)(r.sup,{children:(0,s.jsx)(r.sub,{children:(0,s.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/typed_expr.nr#L7-L9",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/typed_expr.nr#L7-L9"})})})}),"\n"]}),"\n",(0,s.jsxs)(r.p,{children:["If this expression refers to a function definition, returns it. Otherwise returns ",(0,s.jsx)(r.code,{children:"Option::none()"}),"."]}),"\n",(0,s.jsx)(r.h3,{id:"get_type",children:"get_type"}),"\n",(0,s.jsx)(r.pre,{children:(0,s.jsx)(r.code,{className:"language-rust",metastring:'title="get_type" showLineNumbers ',children:"pub comptime fn get_type(self) -> Option<Type> {}\n"})}),"\n",(0,s.jsxs)(r.blockquote,{children:["\n",(0,s.jsx)(r.p,{children:(0,s.jsx)(r.sup,{children:(0,s.jsx)(r.sub,{children:(0,s.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/typed_expr.nr#L13-L15",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/typed_expr.nr#L13-L15"})})})}),"\n"]}),"\n",(0,s.jsxs)(r.p,{children:["Returns the type of the expression, or ",(0,s.jsx)(r.code,{children:"Option::none()"})," if there were errors when the expression was previously resolved."]}),"\n",(0,s.jsx)(r.h3,{id:"location",children:"location"}),"\n",(0,s.jsx)(r.pre,{children:(0,s.jsx)(r.code,{className:"language-rust",metastring:'title="location" showLineNumbers ',children:"pub comptime fn location(self) -> Location {}\n"})}),"\n",(0,s.jsxs)(r.blockquote,{children:["\n",(0,s.jsx)(r.p,{children:(0,s.jsx)(r.sup,{children:(0,s.jsx)(r.sub,{children:(0,s.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/typed_expr.nr#L19-L21",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/typed_expr.nr#L19-L21"})})})}),"\n"]}),"\n",(0,s.jsxs)(r.p,{children:["Returns the source ",(0,s.jsx)(r.a,{href:"/docs/v1.0.0-rc.1/libraries/standard_library/meta/location",children:(0,s.jsx)(r.code,{children:"Location"})})," of this expression.\nThis can be passed to ",(0,s.jsx)(r.code,{children:"std::meta::error"})," or ",(0,s.jsx)(r.code,{children:"std::meta::warn"})," to attach a diagnostic to the expression."]})]})}function p(e={}){const{wrapper:r}={...(0,i.R)(),...e.components};return r?(0,s.jsx)(r,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},28453(e,r,n){n.d(r,{R:()=>o,x:()=>d});var t=n(96540);const s={},i=t.createContext(s);function o(e){const r=t.useContext(i);return t.useMemo(function(){return"function"==typeof e?e(r):{...r,...e}},[r,e])}function d(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),t.createElement(i.Provider,{value:r},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.