diff options
author | Araq <rumpf_a@web.de> | 2018-12-11 10:25:26 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-12-11 10:28:56 +0100 |
commit | 4ec40796e64a6cf9fa34eaaf7de880076f8c2859 (patch) | |
tree | dde28e835368540fdcec13d22ea68cb46dccae69 /compiler | |
parent | 03c4231951c1944a33a4b56823f65fe877e5ccb3 (diff) | |
download | Nim-4ec40796e64a6cf9fa34eaaf7de880076f8c2859.tar.gz |
fixes #9868
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semfold.nim | 8 | ||||
-rw-r--r-- | compiler/semmagic.nim | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 5ec702257..df6298eb0 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -626,6 +626,14 @@ proc getConstExpr(m: PSym, n: PNode; g: ModuleGraph): PNode = # It doesn't matter if the argument is const or not for mLengthArray. # This fixes bug #544. result = newIntNodeT(lengthOrd(g.config, n.sons[1].typ), n, g) + of mSizeOf: + let size = getSize(g.config, n[1].typ) + if size >= 0: + result = newIntNode(nkIntLit, size) + result.info = n.info + result.typ = getSysType(g, n.info, tyInt) + else: + result = nil of mAstToStr: result = newStrNodeT(renderTree(n[1], {renderNoComments}), n, g) of mConStrStr: diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index df2c084a1..7e61854b8 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -321,8 +321,6 @@ proc semOf(c: PContext, n: PNode): PNode = proc magicsAfterOverloadResolution(c: PContext, n: PNode, flags: TExprFlags): PNode = ## This is the preferred code point to implement magics. - ## This function basically works like a macro, with the difference - ## that it is implemented in the compiler and not on the nimvm. ## ``c`` the current module, a symbol table to a very good approximation ## ``n`` the ast like it would be passed to a real macro ## ``flags`` Some flags for more contextual information on how the |