Giter Club home page Giter Club logo

mint's People

Contributors

alex-lairan avatar asterite avatar bbugh avatar dependabot[bot] avatar dohxis avatar eternahl avatar farism avatar gdotdesign avatar hovsater avatar itsgreggreg avatar jansul avatar jonathanoberg avatar jrrom avatar jsmonk avatar manveru avatar matthewmcgarvey avatar namek avatar nilslindemann avatar petemcfarlane avatar pvdvreede avatar s0kil avatar sam647254 avatar sija avatar teddydd avatar tkshnwesper avatar vechro avatar veelenga avatar wisn avatar ymmooot avatar zephraph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mint's Issues

mint start modifies source.

Running mint start changes the sources files to use two space indenting every time I save my files. This really confuses the text editors redo-undo feature, undoing makes Sublime text use half two space indenting and half tab indenting for whatever reason.

I think letting tabs be a thing would help "developer happiness" as something that is being focused on because for me, and other people using non two space indenting that automatic change can be a tad annoying.

mint build accidentally uses non relative path on Ubuntu.

I used mint build and the generated HTML file doesn't work locally because it uses <script src="/index.js"></script> (correct: <script src="./index.js"></script>) which makes the computer think I want a file index.js from the top of the drive. I know mint start can work around that but it would be nice to be able to test out mint build locally.

Add Makefile command for development purpose

The current Makefile commands are build, test, and documentation. The build command compiles Mint and move it to ~/.bin/mint which is the same name as the "stable" command name that I currently used. I think there should be another command for development purpose like compiles Mint and move it to ~/.bin/mint-dev. The point is use different name so we could develop Mint compiler and Mint project with ease.

Does a `\` really look like a Lambda?

I love everything about the language you've created except for those goofy anonymous functions.

\event : Number => handleClick(event)

Maybe its my taste that they just look like escape character over the Haskell logo, but the docs don't exactly say "lambda". If I'm just coming from javascript, there's a lot of things that need to addressed by docs and examples.

Do all lambdas have a Void type? Is it inferred? The examples mention you could pass an anonymous function as a greeter and it just looks confusing:

renderGreeting(\name : String =>
  <div>
    <{ "Hello " + name + "!" }>
  </div>
)

It does seem like you might lock yourself out from future additions. For example, I haven't seen any de-structuring alternative in the language yet. I'm not sure if its something thats ever planned or even already exists; it seems useful and its a big thing in javascript now.

IMO, Arrow functions in Typescript seem pretty good...

(one: Number, { inner, record, values }: ARecord): ResultType => ...

Invalid memory access

This beauty immediately causes an invalid memory access, it works if i change the name of the greeting variable in the where block to something else, but probably shouldn't happen.

record Greetings {
  greeting : String
}

component Main {
  state : Greetings {
    greeting = "ho"
  }

  fun test : Void {
    do {
      next { greeting = greeting }
    }
  } where {
    greeting =
      if (greeting == "hello") {
        "bye"
      } else {
        "hello"
      }
  }

  fun render : Html {
    <div><{ greeting }></div>
  }
}
Invalid memory access (signal 11) at address 0x7ffe0f824e60
[0x685776] ???
[0x46415a] __crystal_sigfault_handler +42
[0x7f0c96c54f10] ???
[0x7f0c96e760ff] ???
[0x7f0c96e7614b] ??? (4 times)
[0x7f0c96e728b5] GC_generic_malloc_many +709
[0x7f0c96e7e76e] GC_malloc_kind +286
[0x550763] ???
[0x5993c0] ???
....
[0x64643e] ???
[0x6409ee] ???
[0x4960e7] ???
[0x447195] __crystal_main +270533
[0x44a493] main +195
[0x7f0c96038b8e] __libc_start_main +238
[0x40501a] _start +42
[0x0] ???

Development server doesn't work in WSL

Running mint start:

josh@DESKTOP-D449P1P:~/dev/test$ mint start
Mint - Running the development server
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙ Ensuring dependencies... 4.017ms
⚙ Compiling... 410.217ms
C:\Users\horiz>netstat -an | grep "3000"
  TCP    127.0.0.1:63919        127.0.0.1:3000         SYN_SENT

Compare this to running ruby's Webrick on localhost:4567

C:\Users\horiz>netstat -an | grep "4567"
  TCP    127.0.0.1:4567         0.0.0.0:0              LISTENING
  TCP    [::1]:4567             [::]:0                 LISTENING

I mentioned in gitter that ruby's thin server had the same behavior, but I just tried it and that appear to have been fixed, however I can't find any reference to what explicitly fixed it.

What makes Mint unique?

For example Elm offers no runtime exceptions, which is amazing.
What makes Mint amazing ?

possible bug with field access on Records

$$CurrentWallet {wallet: $$EncryptedWalletWithName, balances: Array(2)}
balances
:
(2) [$$TokenPair, $$TokenPair]
wallet
:
$$EncryptedWalletWithName
address
:
"VDBkYWQxZjZlZjllOTAzYzNiODQ0NmZkZTI4NDBhYmMzYjUxYThjM2E1ZjNkODlj"
ciphertext
:
"5a288c40c4b5b518ea83723e2b92d2a69c0144493403a227f684c646f2de959e4c758709b7d890676bbd80555388516f023f4cac215839b87d4c89759720102c418344a63953739c608482b1996155234e5f6e7a129edf39afde3a7467a4e23af1704b9c2079ff91c9a61cb1fad2e69ef466b6b46775d89b27bece4e11de9770f621fdbe2be2363951fbf0856a9970b3db063c3f39406af458cfb5b6e503cc74c2a448813620330ea864fb4c0cd8a59aa76969b70244ccc023d4204e6e152aa61aa381d47862874f40466de8368f40c8ea668ac255c8aaa8ad087137eb400c16107ac57dbaf404809a27bbcb5817a292af524f13eed640bd7f41721223e0fb8acba03567c997fdbdf9f2d18ba79b78765a1f6d967181fd759290340e6a8d29798a9cd3619a1cfca6152d1b1f1350cd3446624f9f565f915ec344963d69ae722132959e91e5a7aeac"
name
:
"w1"
salt
:
"$2a$10$7hWFojLVUwHjLZBqwuqAEe"
source
:
"kajiki"
__proto__
:
Record
__proto__
:
Record

I've got a CurrentWallet record
but when I try to use it - I get an error
Debug.log(currentWallet.wallet)
I just get a cryptic error saying: You are tyring to access a field on an object which is not a record: a
(there's a typo in that message too : tyring instead of trying - although I'm finding it pretty tyring so maybe it's accurate hahah!!
as far as I can see - CurrentWallet is a Record - and EncryptedWalletWithName is a record - and so calling wallet on CurrentWallet should return me an EncryptedWalletWithName - but for some reason - it thinks it's not a record?

I think it may be a bug as it was working fine before the upgrade - this happens in several places the currentWallet record is used.

unicode support

Support for foreign character rendering is needed - currently these are rendered as garbage characters

component Main {
  style base {
    font-family: sans;
    font-weight: bold;
    font-size: 50px;

    justify-content: center;
    align-items: center;
    display: flex;
    height: 100vh;
    width: 100vw;
  }

  fun render : Html {
    <div::base>
      <{ "こんにちは" }>
    </div>
  }
}

Incorrect wording of empty store error

The message incorrectly mentioning property which not used by the store anymore.

I was looking for at least one function or property for this store but found
"property" instead.

Allow React Fragments

It doesn't look like its possible to write:

<>
</>

or even

<React.Fragment>
</React.Fragment>

mint start throws up on missing catches

Sorry for the bad title.

If you have a do {} expression, and you don't handle all possible errors, I'm getting the following:

josh@DESKTOP-D449P1P:/mnt/c/users/horiz/dev/snippets-frontend$ mint start
Mint - Running the development server
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙ Ensuring dependencies... 3.129ms
Unhandled exception: Negative count: -97 (ArgumentError)
Failed to raise an exception: END_OF_STACK
[0x6c5b36] ???
[0x464373] __crystal_raise +195
[0x465198] ???
[0x4c17ca] ???
[0x4ba709] ???
[0x4b984e] ???
[0x46c53b] ???
[0x501da9] ???
[0x467e89] main +217
[0x7fe425340830] __libc_start_main +240
[0x419dc9] _start +41

mint build prints:

josh@DESKTOP-D449P1P:/mnt/c/users/horiz/dev/snippets-frontend$ mint build
Mint - Building for production
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙ Ensuring dependencies... 81μs
⚙ Clearing the "dist" directory... 6.955ms
⚙ Compiling your appliction:
  ➔ Parsing 71 source files... 735.821ms
  ➔ Type checking:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

░ TYPE ERROR ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

I am checking if all the possible errors are handled in a do expression.

I found that these types are not handled:

  • Object.Error

Here is the relevant code snippet:

┌───┬ source/Snippet.Store.mint ───────────────────────────────────────────────┐
│137│         do {                                                             │
│138│             next { state | loading = true }                              │
│139│             response = endpoint() + Number.toString(id)                  │
│140│                 |> Http.get()                                            │
│141│                 |> Http.send()                                           │
│142│             object = response.body                                       │
│143│                 |> Json.parse()                                          │
│144│                 |> Maybe.toResult("Json Error")                          │
│145│                                                                          │
│146│             snippet = decode object as Snippet                           │
│147│             next { state | snippet = snippet }                           │
│148│         } catch Http.ErrorResponse => error {                            │
│149│             next { state | error = "Error" }                             │
│150│         } catch String => error {                                        │
│151│             next { state | error = error }                               │
│152│         }                                                                │
│153│     }                                                                    │
│154│                                                                          │
│155│     fun setPage(page : Number) : Void {                                  │
│156│         next { state | page = page }                                     │
│157│     }                                                                    │
│158│                                                                          │
│159│     fun setName(name:String):Void {                                      │
│160│         next { state | snippet = { snippet | name = name }}              │
│161│     }                                                                    │
│162│                                                                          │
│163│     fun setContent(content:String):Void {                                │
│164│         next { state | snippet = { snippet | content = content }}        │
└───┴──────────────────────────────────────────────────────────────────────────┘

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
There was an error exiting...

I'm not 100% sure if this is exactly what's causing it, but I can reproduce it every time by removing a case. If I add the missing case, everything works fine.

the name fun vs function

Is there a reason why functions are call "fun" but things like components, modules, and records are not called "com", "mod" and "rec?"

Add a nice error message about not installed dependencies

When starting a project which have dependencies and are any of them are installed, an unrelated error message appears because an entity (component, store, etc.) cannot be found.

A real example here: mint-lang/example-todo#1

There should be a check for this at some point when doing anything that is related to the compiling (development server, testing, building for production).

The MVP of this feature should be checking if there is a corresponding package in the .mint/packages directory for each package in the dependencies field of the mint.json file of the project.

Tests hang when running on OSX

when running tests on OSX the tests hang - and only by visiting the url: http://localhost:3000 in a browser do they finish. Same problem with Chrome and Firefox

mint test -b firefox
Mint - Running Tests
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙ Compiling tests... 53.232ms
⚙ Starting test server...
⚙ Starting browser...
⚙ Development server started on http://127.0.0.1:3000/
⚙ Running tests:    <---- hung here until I visited the url in the browser 
.    
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1 tests
  ➔ 1 passed
  ➔ 0 failed
Unhandled exception in spawn:  
kill: No such process (Errno)
  from ~procProc(Nil)@src/test_runner.cr:217
  from Fiber#run:(IO::FileDescriptor | Nil)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All done in 37.533s!

Type definition can't have spaces

Syntax Error

A type with parameters must contain at least one parameter.

I was looking for the type or type parameter but found a space instead.

Here is the relevant code snippet:

store Counter.Store {
  property counter : Number = 0
  property trying : Array(  String) = []

  fun increment : Void {
    next { state | counter = counter + 1 }
  }

2018-05-31-215343_622x443_scrot

Consider if..elsif..else

Hi,

When I have multiple conditions to check - e.g.

if (a > 1 && a <3){
  "A"
} else {
 if(a > 3 && a < 5){
  "B"
} else {
  "C"
}
}

It would be nicer to avoid the nesting if there was if..elsif..elsif..else where elsif is optional and can be as many as required.

maybe some kind of if could be applied to case statements to achieve something similar also.

mint build - doesn't work when public dir has a sub folder

Hi

I pulled the latest mint and built it after upgrading to crystal 0.25 - but when I run mint build I get the following error:

Clearing the "dist" directory... 1.034ms
Unhandled exception: Error reading file: Is a directory (Errno)
  from File@Crystal::System::FileDescriptor#unbuffered_read<Slice(UInt8)>:Int32
  from FileUtils@FileUtils::cp<String, String>:Int32
  from Mint::Builder#initialize:Nil
  from Mint::Cli::Build#parse_and_run:Nil
  from __crystal_main
  from main
⚙ Copying public folder contents...

These are the only files I have in my project dir:

ls -al
total 16
drwxr-xr-x  10 c0252355  1001184655   340 17 Jun 21:38 .
drwxr-xr-x  30 c0252355  1001184655  1020 13 Jun 08:52 ..
drwxr-xr-x  16 c0252355  1001184655   544 17 Jun 21:38 .git
-rw-r--r--   1 c0252355  1001184655    10 13 Jun 08:53 .gitignore
drwxr-xr-x   3 c0252355  1001184655   102 13 Jun 08:54 .mint
drwxr-xr-x   3 c0252355  1001184655   102 17 Jun 14:41 assets
drwxr-xr-x   7 c0252355  1001184655   238 17 Jun 21:38 dist
-rw-r--r--   1 c0252355  1001184655   394 13 Jun 08:53 mint.json
drwxr-xr-x   8 c0252355  1001184655   272 17 Jun 15:51 public
drwxr-xr-x   7 c0252355  1001184655   238 17 Jun 21:33 source

provide detect change time flag for adjustment with auto-format

I love the auto-format but it's a bit too quick for me - when I'm typing it doesn't give me enough time to finish what I'm doing and then it reformats - and when I'm in the middle of thinking or being a bit slow - it formats my code away.

So an optional flag that can change the delay would be nice so I can set it to be a bit slower.

What do you think?

Another option is that I add something to my editor to make use of the new format command in the cli and I manually format - this might be a good option as well - that doesn't require any code changes

Allow a component to receive an Array without wrapping in braces

Currently if you want to supply an array to a Component you wrap the array in braces:

<OverviewItem name="BlockChain" items={["item1", "item2"]}/>

It would be nice to supply the array directly - in the same way a string works:

<OverviewItem name="BlockChain" items=["item1", "item2"]/>

original class on html element was replaced when style was applied

I wrote some code like this:

style wider {
  width: 75% !important;
}

<div class="progress">
  <div::wider class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"><{"25%"}></div>
</div>

But when the Html was rendered the original class of "progress-bar" got replaced with the stule one:

<div class="create-wallet-wider" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">25%</div>

Confused about state keyword

I get the idea of having private state in the component, but the sample article confused me.

  1. If state is a keyword, why does it need a : in the example?
  2. How would I declare 2 records as private in a component?
  3. Why not make the keyword private?

Add a minimum of reflection for automatic JSON.

It would be nice for the language to have at least enough reflection for a JSON decoder/encoder to be automatically makeable without using external tools, just with code. This would be to have less boilerplate. And possibly other serialization formats (Protobuf, XML) to be easier to add as libraries.

Edit: I saw Rust had #[derive(Debug)] and Haskell had something similar with Show, so that's an idea.

web site & documentation fail to note that this is a language that compiles to JavaScript

kinda... leaving out the most important bit there.

In fact, the word JavaScript appears exactly zero times in the main web page. I had to read the unit tests to be sure that's what this did because even the documentation for "build for production" fails to mention it.

also, "front end" isn't necessarily the web. Desktop and mobile apps have a "front end" too.

Not decoding a complex data structure. Mint 0.2.1

This code will not decode the json structure:

store Todo.Store {
   state todoList : Array(TodoMainRecord) = [{
         location = "on my harddrive",
         name = "NotePlan",
         todos = [
            {
               deleted = false,
               description = "First one in NP",
               done = false
            },
            {
               deleted = false,
               description = "Second on in NP",
               done = false
            }
         ]
      },
      {
         location = "on my harddrive",
         name = "Todays Todos",
         todos = [
            {
               deleted = false,
               description = "First one in TD",
               done = false
            },
            {
               deleted = false,
               description = "Second on in TD",
               done = false
            }
         ]
      }
   ]

   fun loadTodos () : Void {
      do {
         response = Http.get(Preferences.Store.mainAddress + "/todos")
                     |> Http.send()
         todoJson = Json.parse(response.body)
                     |> Maybe.toResult("Decode Error")
         Debug.log(todoJson)
         todos = decode todoJson as Array(TodoMainRecord)
         Debug.log(todos)
      } catch Http.ErrorResponse => error {
         Debug.log(error)
      } catch String => error {
         Debug.log("Invalid JSON!")
      } catch Object.Error => error {
         Debug.log("Could not decode!")
      }
   }
}

record TodoMainRecord {
   location : String,
   name : String,
   todos : Array(TodoRecord)
}

record TodoRecord {
   deleted : Bool,
   description : String,
   done : Bool
}

The json structure it is trying to load is shown below:

Object todos:Array(2) 
    0: 
        location:"Note Plan" 
        name:"Note Plan" 
        todos:Array(12) 
            0: 
                deleted:false 
                description:"Fill out projected work time for next month [Envato](https://envato.formstack.com/forms/working_arrangement) @Envato" 
                done:false

This is actually just the first object in each structure.

Add Contributing Guideline

We need a contributing guideline with development instructions to avoid error when installing Crystal and so on. There a bit problem when I'm trying to install like SSL library error so it is better to give an instruction to a newcomer who want to contributing to Mint. I'm using Ubuntu 18.04 and I will send a PR for this.

Prettify `mint init` error message

There is an exception raised when we are using mint init command without any path argument supplied.

screenshot from 2018-09-01 22-52-13

Also, here is when the File exists.

screenshot from 2018-09-01 23-04-55

Better error messages from Tests when using JS

Given this test:

suite "Wallet.generateKeyPair" {
  test "should generate a new keyPair" {
    try {
      w = Wallet.go()
      Debug.log(String.size(w.hexPublicKey))

      (String.size(w.hexPublicKey) == 127)   # correct value is 128
    }
  }
}

When the value is incorrect - the test result is:

1 tests
  ➔ 0 passed
  ➔ 1 failed
    should generate a new keyPair
    |> false

When the value is correct the test passes - but as you can see there was no indication that the test failed because the 2 values did not match - if it could say: expected: 127 did not equal actual: 128 or something like that

possible bug with `using` on decoding Json

I have a some Records used for Decoding:

record AddressTransactionsResponse {
  result : Array(Kajiki.Transaction),
  status : String
}

record Kajiki.Sender {
  address : String,
  publicKey : String using "public_key",
  amount : Number,
  fee : Number,
  signr : String using "sign_r",
  signs : String using "sign_s"
}

record Kajiki.Recipient {
  address : String,
  amount : Number
}

record Kajiki.Transaction {
  id : String,
  action : String,
  senders : Array(Kajiki.Sender),
  recipients : Array(Kajiki.Recipient),
  message : String,
  token : String,
  prevHash : String using "prev_hash",
  timestamp : Number,
  scaled : Number
}

and then using it:

  json =
        Json.parse(response.body)
        |> Maybe.toResult("Json parsing error")

      item =
        decode json as TransactionResponse

      txn =
        item.result

      next {transaction1 = Maybe.just(txn) }
    } catch Http.ErrorResponse => error {
      next { error = "Could not retrieve remote wallet information" }
    } catch String => error {
      next { error = "Could not parse json response" }
    } catch Object.Error => error {
      next { error = "could not decode json" }
    }

the json looks fine - but it cannot decode. Instead I get a cryptic javascript error in the console saying

 ReferenceError: $$Kajiki is not defined
    at Function.$$AddressTransactionsResponse.decode (index.js:34460)
    at index.js:37451

the catch lines don't catch anything. this was working fine with from so I suspect it's a bug with using

Consider line comment

A line comment that is different from a block comment would be nice

  1. just typing something like // at the start of the line is much more convenient than putting something at the front and the end

  2. Many editors have the concept of line and block comment - so my intellij plugin for example works a lot better with both.

The existing block comment is great /* */

maybe a line comment could be //

Considering compiling to WebAssembly?

Hi 👋,

From my experience new languages that target JavaScript are great, but they always have a trade-off for the same reason.

Since Mint has types, it should be possible to target WebAssembly instead. While it's quite new (and imposes some limitation at the moment), it's future proof IMO.

I would be happy to help/chat if you have questions.

Syntax Error when using property name that has prefix "with"

I'm playing with mint and started to create a set of Bootstrap 4 components.

Running into a Syntax Error when I have a property called withStyle : String and I attempt to call the value in fun render : Html.

Screenshot:
screenshot 2018-06-10 18 00 39

Component Code:

component BS.Button {
    property text : String = ""
    property disabled : Bool = false
    property type : String = "button"
    property withStyle : String = "primary"
    fun render : Html {
        <button disabled={disabled} class={"btn btn-" + withStyle} type={ type }>
            <{text}>
        </button>
    }
}

Problem:
It appears that the withStyle property is being parsed as a with statement

Workaround:
Use different verbiage for property names

Environment:
Mac OS - 10.12.6
Mint: v0.3.0
Crystal: v0.24.2

Array access

A syntax element is needed to do array access which uses the same brackets as the array literal [] but instead of returning an array it would return the corresponding element in the array.

fun item : Maybe(Number) {
  [1, 1, 2, 3][0] 
}

fun item : Maybe(Number) {
  array[0] 
} where {
  array = [1, 1, 2, 3]
}
  • it can only have one number literal as the index
  • should work on any expression (probably a new branch here: https://github.com/mint-lang/mint/blob/master/src/parsers/expression.cr#L11)
  • type checking needs to be implemented on the expression which should raise an error if it does not evaluate to an array Array(a)
  • the resulting type should be Maybe(a) where a is explicitly set from the result of the expression
  • the JS implementation should be part of the runtime (https://github.com/mint-lang/mint-runtime) (with tests) which is called in the compiled script (_at(array, index))
  • [EXTRA] if the expression can be traced back to an array literal then the compiler should check if there is an item at the given index and raise an error if there isn't one

If you start working on this issue please assign yourself to it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.