Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw Error When Record Does Not Have A Record Definition #317

Closed
Massolari opened this issue Sep 10, 2020 · 4 comments · Fixed by #325
Closed

Throw Error When Record Does Not Have A Record Definition #317

Massolari opened this issue Sep 10, 2020 · 4 comments · Fixed by #325
Labels
bug Something isn't working
Milestone

Comments

@Massolari
Copy link

This code compiles with no errors, but nothing appears in the page:

component Main {
  state data  = { name = "" }
  
  fun setName(newName : String) : Promise(Never, Void) {
  	next { data = { data | name = newName } }
  }
  
  fun handleInput (event : Html.Event) : Promise(Never, Void) {
    event.target
    |> Dom.getValue
    |> setName
  }

  fun render : Html {
  	<div>
      <div>
        <input
          type="text"
          value={data.name}
          onInput={handleInput}
        />
      </div>
      <span><{ data.name }></span>
    </div>
  }
}

In the browser's console, I get:

Uncaught SyntaxError: Unexpected token '}'

Sandbox: https://sandbox.mint-lang.com/sandboxes/COuXNoNlhiAxcQ

@gdotdesign
Copy link
Member

Thanks for reporting, will look into this 👍

@s0kil
Copy link
Contributor

s0kil commented Sep 10, 2020

@Massolari Adding a record to represent state data allows it to compile
Sandbox: https://sandbox.mint-lang.com/sandboxes/zPpR3jZoVQr0qA

@Massolari
Copy link
Author

Massolari commented Sep 10, 2020

@s0kil Thanks! Good to know! I forgot that a record needs a type to represent it. Anyways, the compiler shouldn't let this code compiles

@gdotdesign gdotdesign added the bug Something isn't working label Sep 12, 2020
@gdotdesign gdotdesign added this to the 0.11.0 milestone Sep 14, 2020
@s0kil s0kil changed the title Runtime error after compile Throw Error When Record Does Not Have A Record Definition Sep 21, 2020
@s0kil
Copy link
Contributor

s0kil commented Sep 21, 2020

Scenarios where type checker fails to catch: RecordNotFoundMatchingRecord

component Test {
  property data = { name = "" }

  fun render {
    <{ data.name }>
  }
}

component Main {
  state data = { name = "" }

  fun render {
    <>
      <{ data.name }>
      <Test />
    </>
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants