Comments (17)
Maybe just a wtf
directory, separated into tests which should fail but pass, and vice-versa.
from nimskull.
Error: invalid order in enum 'c_GIT_DIFF_IGNORE_BLANK_LINES'
int is 32 bit for JS VM/backend; this works
type
c_git_diff_option_t* = enum
c_GIT_DIFF_NORMAL = 0 shl 0
c_GIT_DIFF_IGNORE_BLANK_LINES = 1'i64 shl 31
from nimskull.
Maybe just a
wtf
directory, separated into tests which should fail but pass, and vice-versa.
https://github.com/nim-lang/Nim/labels/accepts%20invalid as a start
from nimskull.
Nice comment on macros.
from nimskull.
For tests that involve types also check everything with distinct.
So it's good to put the 3 permutations of them in different places
A distinct to a type, a generic distinct, and a distinct of a generic distinct
Basically anywhere you should be able to put a type ensure you put those distincts
type
A = distinct int
B[T] = distinct A
C = distinct B[string]
from nimskull.
I would much rather prefer to have some built-in language construct to assert compilation errors, instead of testament hack
let failure = getFailedNkErrorNodes:
SomeCodeThatMakesNoSenseSemantically
doAssert failure.description.contains "illegal recursion in type 'Object'"
discard """
cmd: "nim check $file"
nimout: '''teffects1.nim(22, 28) template/generic instantiation from here
teffects1.nim(23, 13) Error: can raise an unlisted exception: ref IOError
teffects1.nim(22, 29) Hint: 'lier' cannot raise 'IO2Error' [XCannotRaiseY]
teffects1.nim(38, 21) Error: type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
.raise effects differ'''
"""
{.push warningAsError[Effect]: on.}
type
TObj {.pure, inheritable.} = object
TObjB = object of TObj
a, b, c: string
IO2Error = ref object of IOError
proc forw: int {. .}
proc lier(): int {.raises: [IO2Error].} =
#[tt.Hint ^ 'lier' cannot raise 'IO2Error' [XCannotRaiseY] ]#
writeLine stdout, "arg" #[tt.Error
^ can raise an unlisted exception: ref IOError
]#
proc forw: int =
raise newException(IOError, "arg")
{.push raises: [Defect].}
type
MyProcType* = proc(x: int): string #{.raises: [ValueError, Defect].}
proc foo(x: int): string {.raises: [ValueError].} =
if x > 9:
raise newException(ValueError, "Use single digit")
$x
var p: MyProcType = foo #[tt.Error
^
type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
]#
{.pop.}
{.pop.}
from nimskull.
Todo items from specification PR reviews by @saem
- areas of future improvement to be noted, precedence/parsing rules for how the command syntax collects arguments and interaction with other ones. link
- Todo, to be noted for later, I think the formal semantics of this should be a lowering to a combination of procedures that takes the arguments, or not if default, and then have code in the body to carry out the expressions to access fields and stuff. link
- Todo, noted for later, need to add in the rules for loop items/pairs inference. It should actually be changed, like either static interfaces, rows, concepts, or something to make it work nicely. link
from nimskull.
There is another thing important about generics. Generic instanciation time needs to be specified. Generally speaking generics are instanciated at first usage. And this alone wouldn't need a specificaiton, But nim doesn't order independent. The order in which functions are declared matters. And the amount of converters and functions and types known to the compiler at the time a generic is instanciated affects what the generic will eventually resolve to. It might be that the generic instanciates with a converter function too early. At a later instanciation time the generic might have found a better overload without conversion.
from nimskull.
min/max value ranges for enums
type
c_git_diff_option_t* = enum
c_GIT_DIFF_NORMAL = 0 shl 0
c_GIT_DIFF_IGNORE_BLANK_LINES = 1 shl 31
^ ok for nim c
and nim cpp
, but fails for js Error: invalid order in enum 'c_GIT_DIFF_IGNORE_BLANK_LINES'
from nimskull.
Thanks, @xflywind
from nimskull.
I'm poking at pragmas as part of nkError work, please add as tests.
For reference the nkRrror/pragma work is here: d2368ef#diff-1d1109c3f7bc16cf4e770fe792e9073bff67591721f3c72b96cb4b4a3b76bd88R806
from nimskull.
I think it would be a good idea to also specify how compiler reads the environment - nim.cfg
, project.nim.cfg
, in which order, how configuration entries override each other and so on.
from nimskull.
Specify and provide examples of where each defect is raised, and if possible - how it can be prevented (like cast to unchecked assign, maybe there are some extra features like these that I don't know of).
from nimskull.
Language specification should include specific explanation of some basic concepts that are considered as "no need to explain, obvious to everyone". If anything, this could be used as a basis for introducing newcomers to a fundamentally new concepts that might not exist in their language.
- compile time
- side effect
- typed and untyped macros - this one is tricky, but the whole concept of semantic analysis is not something an average user probably familiar with, so it warrants special attention.
from nimskull.
Fundamental concepts that aren't or are poorly described:
- errors
- type inference
- resolution, dispatch, and overloads
- module resolution
- type tagging, untagging, and comparison
- differences between backends
- core defines and the environment
from nimskull.
From the tests above -
- OrderedTable is not an
object
for some reason - Putting explicit generic parameters in
load
in theroundTrip
leads to compiler thinking thatseq
is anenum
and anobject
at the same time F/Y/Z
is not anobject
, butJsonNode
is when doing overload, at the same timeF is object
yields trueF is object
andF is object | tuple | ref object
butF isnot Object
wheretype Object = object | tuple | ref object
from nimskull.
Split into smaller todo lists
from nimskull.
Related Issues (20)
- Testament doesn't show a diff for nimout failures
- testament in `sexp` mode fails on Windows HOT 10
- RST syntax errors in docgen are not reported properly HOT 1
- Add Windows binaries to GitHub Actions
- Add a package manager to pre-built binaries HOT 2
- Wrong behaviour at runtime with templates and `var`/`lent` tuples
- Cyo/Nimskull fails to compile on Termux, aarch64, due to issues with glob HOT 1
- Decouple parser from PNode with DOD approach HOT 3
- refactor: compiler output/reports modules design and faster compile time HOT 1
- Dedicated VSCode Extension HOT 3
- LSP (Language Server Protocol) Replacement for Nimsuggest
- Exclude `reKnownIssue` from the "print failed tests" stage in CI HOT 3
- Rebase https://github.com/nim-works/nimskull/pull/135
- vtable method dispatch HOT 8
- sort the standard library test directory `tests/stdlib`
- Canonicalized filepaths has a large performance impact on compilation speed HOT 1
- Remove `bind` and `mixin` from generics HOT 2
- range checked integer types HOT 2
- language design - `compileTime` pragma: symbol visibility, types, and transfering procedural values
- Include valgrind as part of CI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nimskull.